jblanked 9 mesi fa
parent
commit
a69090bccb
48 ha cambiato i file con 0 aggiunte e 9380 eliminazioni
  1. BIN
      .DS_Store
  2. 0 45
      README.md
  3. 0 77
      alloc/flip_store_alloc.c
  4. 0 10
      alloc/flip_store_alloc.h
  5. 0 55
      app.c
  6. BIN
      app.png
  7. 0 14
      application.fam
  8. 0 213
      apps/flip_store_apps.c
  9. 0 52
      apps/flip_store_apps.h
  10. BIN
      assets/01-main-menu.png
  11. BIN
      assets/02-catalog.png
  12. BIN
      assets/03-list.png
  13. BIN
      assets/04-success.png
  14. BIN
      assets/05-browse.png
  15. BIN
      assets/ButtonBACK_10x8.png
  16. BIN
      assets/ButtonLeft_4x7.png
  17. BIN
      assets/ButtonOK_7x7.png
  18. BIN
      assets/ButtonRight_4x7.png
  19. BIN
      assets/ButtonUp_7x4.png
  20. 0 42
      assets/CHANGELOG.md
  21. BIN
      assets/KeyBackspaceSelected_16x9.png
  22. BIN
      assets/KeyBackspace_16x9.png
  23. BIN
      assets/KeySaveSelected_24x11.png
  24. BIN
      assets/KeySave_24x11.png
  25. 0 44
      assets/README.md
  26. BIN
      assets/WarningDolphin_45x42.png
  27. 0 1819
      callback/flip_store_callback.c
  28. 0 77
      callback/flip_store_callback.h
  29. 0 590
      easy_flipper/easy_flipper.c
  30. 0 269
      easy_flipper/easy_flipper.h
  31. 0 106
      firmwares/flip_store_firmwares.c
  32. 0 31
      firmwares/flip_store_firmwares.h
  33. 0 446
      flip_storage/flip_store_storage.c
  34. 0 40
      flip_storage/flip_store_storage.h
  35. 0 67
      flip_store.c
  36. 0 121
      flip_store.h
  37. 0 1826
      flipper_http/flipper_http.c
  38. 0 407
      flipper_http/flipper_http.h
  39. 0 378
      github/flip_store_github.c
  40. 0 26
      github/flip_store_github.h
  41. 0 803
      jsmn/jsmn.c
  42. 0 74
      jsmn/jsmn.h
  43. 0 736
      jsmn/jsmn_furi.c
  44. 0 74
      jsmn/jsmn_furi.h
  45. 0 15
      jsmn/jsmn_h.c
  46. 0 56
      jsmn/jsmn_h.h
  47. 0 784
      text_input/uart_text_input.c
  48. 0 83
      text_input/uart_text_input.h

BIN
assets/.DS_Store → .DS_Store


+ 0 - 45
README.md

@@ -1,45 +0,0 @@
-# FlipStore
-Download Flipper Zero apps directly to your Flipper Zero using WiFi. 
-
-## Features
-- App Catalog
-- Install Apps
-- Delete Apps 
-- Install WiFi Developer Board Firmware
-- Install Video Game Module Firmware
-- Install GitHub Repositories (Beta)
-- Install Official Firmware (coming soon)
-
-## Installation
-1. Flash your WiFi Dveloper Board or Raspberry Pi Pico W: https://github.com/jblanked/FlipperHTTP
-2. Install the app.
-3. Enjoy :D
-
-## Roadmap
-**v0.2**
-- Stability Patch
-- App Categories
-
-**v0.3**
-- Improved memory allocation
-- Stability Patch 2
-- App Catalog Patch (add in required functionalility)
-
-**v0.4**
-- Delete Apps
-
-**v0.5**
-- App short description
-- App version
-
-**v0.6**
-- Download flash firmware (Marauder, Black Magic, FlipperHTTP)
-
-**v0.7**
-- UX Improvements
-
-**v0.8**
-- Download GitHub repositories
-
-**1.0**
-- Download Official Flipper Zero Firmware

+ 0 - 77
alloc/flip_store_alloc.c

@@ -1,77 +0,0 @@
-#include <alloc/flip_store_alloc.h>
-// Function to allocate resources for the FlipStoreApp
-FlipStoreApp *flip_store_app_alloc()
-{
-    FlipStoreApp *app = (FlipStoreApp *)malloc(sizeof(FlipStoreApp));
-
-    Gui *gui = furi_record_open(RECORD_GUI);
-
-    // Allocate ViewDispatcher
-    if (!easy_flipper_set_view_dispatcher(&app->view_dispatcher, gui, app))
-    {
-        return NULL;
-    }
-    view_dispatcher_set_custom_event_callback(app->view_dispatcher, flip_store_custom_event_callback);
-
-    // Main view
-    if (!easy_flipper_set_view(&app->view_loader, FlipStoreViewLoader, flip_store_loader_draw_callback, NULL, callback_to_submenu_options, &app->view_dispatcher, app))
-    {
-        return NULL;
-    }
-    flip_store_loader_init(app->view_loader);
-
-    if (!easy_flipper_set_widget(&app->widget_result, FlipStoreViewWidgetResult, "Error, try again.", callback_to_submenu_options, &app->view_dispatcher))
-    {
-        return NULL;
-    }
-
-    // Submenu
-    if (!easy_flipper_set_submenu(&app->submenu_main, FlipStoreViewSubmenu, VERSION_TAG, callback_exit_app, &app->view_dispatcher))
-    {
-        return NULL;
-    }
-    if (!easy_flipper_set_submenu(&app->submenu_options, FlipStoreViewSubmenuOptions, "Browse", callback_to_submenu, &app->view_dispatcher))
-    {
-        return NULL;
-    }
-    if (!easy_flipper_set_submenu(&app->submenu_app_list, FlipStoreViewAppList, "App Catalog", callback_to_submenu_options, &app->view_dispatcher))
-    {
-        return NULL;
-    }
-    if (!easy_flipper_set_submenu(&app->submenu_firmwares, FlipStoreViewFirmwares, "ESP32 Firmware", callback_to_submenu_options, &app->view_dispatcher))
-    {
-        return NULL;
-    }
-    if (!easy_flipper_set_submenu(&app->submenu_vgm_firmwares, FlipStoreViewVGMFirmwares, "VGM Firmware", callback_to_submenu_options, &app->view_dispatcher))
-    {
-        return NULL;
-    }
-
-    //
-    submenu_add_item(app->submenu_main, "Browse", FlipStoreSubmenuIndexOptions, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_main, "About", FlipStoreSubmenuIndexAbout, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_main, "Settings", FlipStoreSubmenuIndexSettings, callback_submenu_choices, app);
-    //
-    submenu_add_item(app->submenu_options, "App Catalog", FlipStoreSubmenuIndexAppList, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_options, "ESP32 Firmware", FlipStoreSubmenuIndexFirmwares, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_options, "VGM Firmware", FlipStoreSubmenuIndexVGMFirmwares, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_options, "GitHub Repository", FlipStoreSubmenuIndexGitHub, callback_submenu_choices, app);
-    //
-    submenu_add_item(app->submenu_app_list, "Bluetooth", FlipStoreSubmenuIndexAppListBluetooth, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_app_list, "Games", FlipStoreSubmenuIndexAppListGames, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_app_list, "GPIO", FlipStoreSubmenuIndexAppListGPIO, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_app_list, "Infrared", FlipStoreSubmenuIndexAppListInfrared, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_app_list, "iButton", FlipStoreSubmenuIndexAppListiButton, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_app_list, "Media", FlipStoreSubmenuIndexAppListMedia, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_app_list, "NFC", FlipStoreSubmenuIndexAppListNFC, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_app_list, "RFID", FlipStoreSubmenuIndexAppListRFID, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_app_list, "Sub-GHz", FlipStoreSubmenuIndexAppListSubGHz, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_app_list, "Tools", FlipStoreSubmenuIndexAppListTools, callback_submenu_choices, app);
-    submenu_add_item(app->submenu_app_list, "USB", FlipStoreSubmenuIndexAppListUSB, callback_submenu_choices, app);
-    //
-
-    // Switch to the main view
-    view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewSubmenu);
-
-    return app;
-}

+ 0 - 10
alloc/flip_store_alloc.h

@@ -1,10 +0,0 @@
-#ifndef FLIP_STORE_I_H
-#define FLIP_STORE_I_H
-
-#include <flip_store.h>
-#include <callback/flip_store_callback.h>
-
-// Function to allocate resources for the FlipStoreApp
-FlipStoreApp *flip_store_app_alloc();
-
-#endif // FLIP_STORE_I_H

+ 0 - 55
app.c

@@ -1,55 +0,0 @@
-#include <flip_store.h>
-#include <alloc/flip_store_alloc.h>
-
-// Entry point for the Hello World application
-int32_t main_flip_store(void *p)
-{
-    // Suppress unused parameter warning
-    UNUSED(p);
-
-    // Initialize the Hello World application
-    FlipStoreApp *app = flip_store_app_alloc();
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "Failed to allocate FlipStoreApp");
-        return -1;
-    }
-
-    // check if board is connected (Derek Jamison)
-    FlipperHTTP *fhttp = flipper_http_alloc();
-    if (!fhttp)
-    {
-        easy_flipper_dialog("FlipperHTTP Error", "The UART is likely busy.\nEnsure you have the correct\nflash for your board then\nrestart your Flipper Zero.");
-        return -1;
-    }
-
-    if (!flipper_http_ping(fhttp))
-    {
-        FURI_LOG_E(TAG, "Failed to ping the device");
-        flipper_http_free(fhttp);
-        return -1;
-    }
-
-    // Try to wait for pong response.
-    uint32_t counter = 10;
-    while (fhttp->state == INACTIVE && --counter > 0)
-    {
-        FURI_LOG_D(TAG, "Waiting for PONG");
-        furi_delay_ms(100);
-    }
-
-    flipper_http_free(fhttp);
-    if (counter == 0)
-    {
-        easy_flipper_dialog("FlipperHTTP Error", "Ensure your WiFi Developer\nBoard or Pico W is connected\nand the latest FlipperHTTP\nfirmware is installed.");
-    }
-
-    // Run the view dispatcher
-    view_dispatcher_run(app->view_dispatcher);
-
-    // Free the resources used by the Hello World application
-    flip_store_app_free(app);
-
-    // Return 0 to indicate success
-    return 0;
-}

BIN
app.png


+ 0 - 14
application.fam

@@ -1,14 +0,0 @@
-App(
-    appid="flip_store",
-    name="FlipStore",
-    apptype=FlipperAppType.EXTERNAL,
-    entry_point="main_flip_store",
-    stack_size=4 * 1024,
-    fap_icon="app.png",
-    fap_category="GPIO",
-    fap_icon_assets="assets",
-    fap_description="Download apps via WiFi directly to your Flipper Zero",
-    fap_author="JBlanked",
-    fap_weburl="https://github.com/jblanked/FlipStore",
-    fap_version="0.8",
-)

+ 0 - 213
apps/flip_store_apps.c

@@ -1,213 +0,0 @@
-#include <apps/flip_store_apps.h>
-
-FlipStoreAppInfo *flip_catalog = NULL;
-
-uint32_t app_selected_index = 0;
-uint32_t flip_store_category_index = 0;
-int catalog_iteration = 0;
-
-// define the list of categories
-char *category_ids[] = {
-    "64a69817effe1f448a4053b4", // "Bluetooth",
-    "64971d11be1a76c06747de2f", // "Games",
-    "64971d106617ba37a4bc79b9", // "GPIO",
-    "64971d106617ba37a4bc79b6", // "Infrared",
-    "64971d11be1a76c06747de29", // "iButton",
-    "64971d116617ba37a4bc79bc", // "Media",
-    "64971d10be1a76c06747de26", // "NFC",
-    "64971d10577d519190ede5c2", // "RFID",
-    "64971d0f6617ba37a4bc79b3", // "Sub-GHz",
-    "64971d11577d519190ede5c5", // "Tools",
-    "64971d11be1a76c06747de2c", // "USB",
-};
-
-char *categories[] = {
-    "Bluetooth", // "64a69817effe1f448a4053b4"
-    "Games",     // "64971d11be1a76c06747de2f"
-    "GPIO",      // "64971d106617ba37a4bc79b9"
-    "Infrared",  // "64971d106617ba37a4bc79b6"
-    "iButton",   // "64971d11be1a76c06747de29"
-    "Media",     // "64971d116617ba37a4bc79bc"
-    "NFC",       // "64971d10be1a76c06747de26"
-    "RFID",      // "64971d10577d519190ede5c2"
-    "Sub-GHz",   // "64971d0f6617ba37a4bc79b3"
-    "Tools",     // "64971d11577d519190ede5c5"
-    "USB",       // "64971d11be1a76c06747de2c"
-};
-
-FlipStoreAppInfo *flip_catalog_alloc()
-{
-    if (memmgr_get_free_heap() < MAX_APP_COUNT * sizeof(FlipStoreAppInfo))
-    {
-        FURI_LOG_E(TAG, "Not enough memory to allocate flip_catalog.");
-        return NULL;
-    }
-    FlipStoreAppInfo *app_catalog = malloc(MAX_APP_COUNT * sizeof(FlipStoreAppInfo));
-    if (!app_catalog)
-    {
-        FURI_LOG_E(TAG, "Failed to allocate memory for flip_catalog.");
-        return NULL;
-    }
-    app_catalog->count = 0;
-    app_catalog->iteration = catalog_iteration;
-    return app_catalog;
-}
-
-void flip_catalog_free()
-{
-    if (flip_catalog)
-    {
-        free(flip_catalog);
-        flip_catalog = NULL;
-    }
-}
-
-bool flip_store_process_app_list(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP is NULL.");
-        return false;
-    }
-    // Initialize the flip_catalog
-    flip_catalog = flip_catalog_alloc();
-    if (!flip_catalog)
-    {
-        FURI_LOG_E(TAG, "Failed to allocate memory for flip_catalog.");
-        return false;
-    }
-
-    FuriString *feed_data = flipper_http_load_from_file(fhttp->file_path);
-    if (feed_data == NULL)
-    {
-        FURI_LOG_E(TAG, "Failed to load received data from file.");
-        return false;
-    }
-
-    FuriString *json_data_str = furi_string_alloc();
-    if (!json_data_str)
-    {
-        FURI_LOG_E("Game", "Failed to allocate json_data string");
-        return NULL;
-    }
-    furi_string_cat_str(json_data_str, "{\"json_data\":");
-    if (memmgr_get_free_heap() < furi_string_size(feed_data) + furi_string_size(json_data_str) + 2)
-    {
-        FURI_LOG_E(TAG, "Not enough memory to allocate json_data_str.");
-        furi_string_free(feed_data);
-        furi_string_free(json_data_str);
-        return false;
-    }
-    furi_string_cat(json_data_str, feed_data);
-    furi_string_free(feed_data);
-    furi_string_cat_str(json_data_str, "}");
-
-    flip_catalog->count = 0;
-
-    // parse the JSON data
-    for (int i = 0; i < MAX_APP_COUNT; i++)
-    {
-        FuriString *json_data_array = get_json_array_value_furi("json_data", i, json_data_str);
-        if (!json_data_array)
-        {
-            break;
-        }
-
-        FuriString *app_id = get_json_value_furi("alias", json_data_array);
-        if (!app_id)
-        {
-            FURI_LOG_E(TAG, "Failed to get app_id.");
-            furi_string_free(json_data_array);
-            break;
-        }
-        snprintf(flip_catalog[i].app_id, MAX_ID_LENGTH, "%s", furi_string_get_cstr(app_id));
-        furi_string_free(app_id);
-
-        FuriString *current_version = get_json_value_furi("current_version", json_data_array);
-        if (!current_version)
-        {
-            FURI_LOG_E(TAG, "Failed to get current_version.");
-            furi_string_free(json_data_array);
-            break;
-        }
-
-        FuriString *app_name = get_json_value_furi("name", current_version);
-        if (!app_name)
-        {
-            FURI_LOG_E(TAG, "Failed to get app_name.");
-            furi_string_free(json_data_array);
-            furi_string_free(current_version);
-            break;
-        }
-        snprintf(flip_catalog[i].app_name, MAX_APP_NAME_LENGTH, "%s", furi_string_get_cstr(app_name));
-        furi_string_free(app_name);
-
-        FuriString *app_description = get_json_value_furi("short_description", current_version);
-        if (!app_description)
-        {
-            FURI_LOG_E(TAG, "Failed to get app_description.");
-            furi_string_free(json_data_array);
-            furi_string_free(current_version);
-            break;
-        }
-        snprintf(flip_catalog[i].app_description, MAX_APP_DESCRIPTION_LENGTH, "%s", furi_string_get_cstr(app_description));
-        furi_string_free(app_description);
-
-        FuriString *app_version = get_json_value_furi("version", current_version);
-        if (!app_version)
-        {
-            FURI_LOG_E(TAG, "Failed to get app_version.");
-            furi_string_free(json_data_array);
-            furi_string_free(current_version);
-            break;
-        }
-        snprintf(flip_catalog[i].app_version, MAX_APP_VERSION_LENGTH, "%s", furi_string_get_cstr(app_version));
-        furi_string_free(app_version);
-
-        FuriString *_id = get_json_value_furi("_id", current_version);
-        if (!_id)
-        {
-            FURI_LOG_E(TAG, "Failed to get _id.");
-            furi_string_free(json_data_array);
-            furi_string_free(current_version);
-            break;
-        }
-        snprintf(flip_catalog[i].app_build_id, MAX_ID_LENGTH, "%s", furi_string_get_cstr(_id));
-        furi_string_free(_id);
-
-        flip_catalog->count++;
-        furi_string_free(json_data_array);
-        furi_string_free(current_version);
-    }
-
-    furi_string_free(json_data_str);
-    return flip_catalog->count > 0;
-}
-
-static bool flip_store_get_fap_file(FlipperHTTP *fhttp, char *build_id, uint8_t target, uint16_t api_major, uint16_t api_minor)
-{
-    if (!fhttp || !build_id)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP or build_id is NULL.");
-        return false;
-    }
-    char url[256];
-    fhttp->save_received_data = false;
-    fhttp->is_bytes_request = true;
-    snprintf(url, sizeof(url), "https://catalog.flipperzero.one/api/v0/application/version/%s/build/compatible?target=f%d&api=%d.%d", build_id, target, api_major, api_minor);
-    return flipper_http_get_request_bytes(fhttp, url, "{\"Content-Type\": \"application/octet-stream\"}");
-}
-
-bool flip_store_install_app(FlipperHTTP *fhttp, char *category)
-{
-    if (!fhttp || !category)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP or category is NULL.");
-        return false;
-    }
-    snprintf(fhttp->file_path, sizeof(fhttp->file_path), STORAGE_EXT_PATH_PREFIX "/apps/%s/%s.fap", category, flip_catalog[app_selected_index].app_id);
-    uint8_t target = furi_hal_version_get_hw_target();
-    uint16_t api_major, api_minor;
-    furi_hal_info_get_api_version(&api_major, &api_minor);
-    return flip_store_get_fap_file(fhttp, flip_catalog[app_selected_index].app_build_id, target, api_major, api_minor);
-}

+ 0 - 52
apps/flip_store_apps.h

@@ -1,52 +0,0 @@
-#ifndef FLIP_STORE_APPS_H
-#define FLIP_STORE_APPS_H
-
-#include <flip_store.h>
-#include <flip_storage/flip_store_storage.h>
-#include <callback/flip_store_callback.h>
-
-// Define maximum limits
-#define MAX_APP_NAME_LENGTH 32
-#define MAX_ID_LENGTH 32
-#define MAX_APP_COUNT 50
-#define MAX_APP_DESCRIPTION_LENGTH 100
-#define MAX_APP_VERSION_LENGTH 5
-
-// define the list of categories
-extern char *category_ids[];
-extern char *categories[];
-extern int catalog_iteration;
-
-typedef struct
-{
-    char app_name[MAX_APP_NAME_LENGTH];
-    char app_id[MAX_APP_NAME_LENGTH];
-    char app_build_id[MAX_ID_LENGTH];
-    char app_version[MAX_APP_VERSION_LENGTH];
-    char app_description[MAX_APP_DESCRIPTION_LENGTH];
-    size_t count;
-    int iteration;
-} FlipStoreAppInfo;
-
-extern FlipStoreAppInfo *flip_catalog;
-extern uint32_t app_selected_index;
-extern uint32_t flip_store_category_index;
-
-enum ObjectState
-{
-    OBJECT_EXPECT_KEY,
-    OBJECT_EXPECT_COLON,
-    OBJECT_EXPECT_VALUE,
-    OBJECT_EXPECT_COMMA_OR_END
-};
-
-FlipStoreAppInfo *flip_catalog_alloc();
-
-void flip_catalog_free();
-
-// Utility function to parse JSON incrementally from a file
-bool flip_store_process_app_list(FlipperHTTP *fhttp);
-
-// function to handle the entire installation process "asynchronously"
-bool flip_store_install_app(FlipperHTTP *fhttp, char *category);
-#endif // FLIP_STORE_APPS_H

BIN
assets/01-main-menu.png


BIN
assets/02-catalog.png


BIN
assets/03-list.png


BIN
assets/04-success.png


BIN
assets/05-browse.png


BIN
assets/ButtonBACK_10x8.png


BIN
assets/ButtonLeft_4x7.png


BIN
assets/ButtonOK_7x7.png


BIN
assets/ButtonRight_4x7.png


BIN
assets/ButtonUp_7x4.png


+ 0 - 42
assets/CHANGELOG.md

@@ -1,42 +0,0 @@
-## v0.8
-- Updated FlipperHTTP to the latest library.
-- Switched to use Flipper catalog API.
-- Added an option to download Video Game Module firmware (FlipperHTTP)
-- Added an option to download Github repositories.
-- Updated Marauder to the version 1.2
-
-## v0.7.2
-- Final memory allocation improvements
-
-## v0.7.1
-- Improved memory allocation
-- Fixed a crash when re-entering the same app list  
-
-## v0.7
-- Improved memory allocation
-- Added updates from Derek Jamison
-- Updated Marauder to the latest version
-
-## v0.6
-- Updated app layout
-- Added an option to download Developer Board firmware (Black Magic, FlipperHTTP, and Marauder)
-
-## v0.5
-- Added app descriptions and versioning
-
-## v0.4
-- Added an option to delete apps
-- Edits by Willy-JL
-
-## v0.3
-- Edits by Willy-JL
-- Improved memory allocation
-- Stability patch
-
-## v0.2
-- Added categories: Users can now navigate through categories, and when FlipStore installs a selected app, it downloads directly to the corresponding category folder in the apps directory
-- Improved memory allocation to prevent "Out of Memory" warnings
-- Updated installation messages
-
-## v0.1
-- Initial release

BIN
assets/KeyBackspaceSelected_16x9.png


BIN
assets/KeyBackspace_16x9.png


BIN
assets/KeySaveSelected_24x11.png


BIN
assets/KeySave_24x11.png


+ 0 - 44
assets/README.md

@@ -1,44 +0,0 @@
-Download Flipper Zero apps directly to your Flipper Zero using WiFi. 
-
-## Features
-- App Catalog
-- Install Apps
-- Delete Apps 
-- Install WiFi Developer Board Firmware
-- Install Video Game Module Firmware
-- Install GitHub Repositories (Beta)
-- Install Official Firmware (coming soon)
-
-## Installation
-1. Flash your WiFi Dveloper Board or Raspberry Pi Pico W: https://github.com/jblanked/FlipperHTTP
-2. Install the app.
-3. Enjoy :D
-
-## Roadmap
-**v0.2**
-- Stability Patch
-- App Categories
-
-**v0.3**
-- Improved memory allocation
-- Stability Patch 2
-- App Catalog Patch (add in required functionalility)
-
-**v0.4**
-- Delete Apps
-
-**v0.5**
-- App short description
-- App version
-
-**v0.6**
-- Download flash firmware (Marauder, Black Magic, FlipperHTTP)
-
-**v0.7**
-- UX Improvements
-
-**v0.8**
-- Download GitHub repositories
-
-**1.0**
-- Download Official Flipper Zero Firmware

BIN
assets/WarningDolphin_45x42.png


+ 0 - 1819
callback/flip_store_callback.c

@@ -1,1819 +0,0 @@
-#include <callback/flip_store_callback.h>
-#include <github/flip_store_github.h>
-
-// Below added by Derek Jamison
-// FURI_LOG_DEV will log only during app development. Be sure that Settings/System/Log Device is "LPUART"; so we dont use serial port.
-#ifdef DEVELOPMENT
-#define FURI_LOG_DEV(tag, format, ...) furi_log_print_format(FuriLogLevelInfo, tag, format, ##__VA_ARGS__)
-#define DEV_CRASH() furi_crash()
-#else
-#define FURI_LOG_DEV(tag, format, ...)
-#define DEV_CRASH()
-#endif
-
-bool flip_store_app_does_exist = false;
-uint32_t selected_firmware_index = 0;
-static uint32_t callback_to_app_category_list(void *context);
-
-static bool flip_store_dl_app_fetch(DataLoaderModel *model)
-{
-    if (!model->fhttp)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP is NULL");
-        return false;
-    }
-    return flip_store_install_app(model->fhttp, categories[flip_store_category_index]);
-}
-static char *flip_store_dl_app_parse(DataLoaderModel *model)
-{
-    if (!model->fhttp || model->fhttp->state != IDLE)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP is NULL or not IDLE");
-        return "Failed to install app.";
-    }
-    return "App installed successfully.";
-}
-static void flip_store_dl_app_switch_to_view(FlipStoreApp *app)
-{
-    flip_store_generic_switch_to_view(app, flip_catalog[app_selected_index].app_name, flip_store_dl_app_fetch, flip_store_dl_app_parse, 1, callback_to_app_category_list, FlipStoreViewLoader);
-}
-//
-static bool flip_store_fetch_firmware(DataLoaderModel *model)
-{
-    if (!model->fhttp)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP is NULL");
-        return false;
-    }
-    model->fhttp->state = IDLE;
-    if (model->request_index == 0)
-    {
-        firmware_free();
-        firmwares = firmware_alloc();
-        if (!firmwares)
-        {
-            return false;
-        }
-        return flip_store_get_firmware_file(
-            model->fhttp,
-            firmwares[selected_firmware_index].links[0],
-            firmwares[selected_firmware_index].name,
-            strrchr(firmwares[selected_firmware_index].links[0], '/') + 1);
-    }
-    else if (model->request_index == 1)
-    {
-        return flip_store_get_firmware_file(
-            model->fhttp,
-            firmwares[selected_firmware_index].links[1],
-            firmwares[selected_firmware_index].name,
-            strrchr(firmwares[selected_firmware_index].links[1], '/') + 1);
-    }
-    else if (model->request_index == 2)
-    {
-        return flip_store_get_firmware_file(
-            model->fhttp,
-            firmwares[selected_firmware_index].links[2],
-            firmwares[selected_firmware_index].name,
-            strrchr(firmwares[selected_firmware_index].links[2], '/') + 1);
-    }
-    return false;
-}
-static char *flip_store_parse_firmware(DataLoaderModel *model)
-{
-    if (model->request_index == 0)
-    {
-        return "File 1 installed.";
-    }
-    else if (model->request_index == 1)
-    {
-        return "File 2 installed.";
-    }
-    else if (model->request_index == 2)
-    {
-        return "Firmware downloaded successfully";
-    }
-    return "Failed to download firmware.";
-}
-static void flip_store_switch_to_firmware_list(FlipStoreApp *app)
-{
-    flip_store_generic_switch_to_view(app, firmwares[selected_firmware_index].name, flip_store_fetch_firmware, flip_store_parse_firmware, FIRMWARE_LINKS, callback_to_firmware_list, FlipStoreViewLoader);
-}
-//
-static bool flip_store_fetch_vgm_firmware(DataLoaderModel *model)
-{
-    if (!model->fhttp)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP is NULL");
-        return false;
-    }
-    model->fhttp->state = IDLE;
-    if (model->request_index == 0)
-    {
-        vgm_firmware_free();
-        vgm_firmwares = vgm_firmware_alloc();
-        if (!vgm_firmwares)
-        {
-            return false;
-        }
-        return flip_store_get_firmware_file(
-            model->fhttp,
-            vgm_firmwares[selected_firmware_index].link,
-            vgm_firmwares[selected_firmware_index].name,
-            strrchr(vgm_firmwares[selected_firmware_index].link, '/') + 1);
-    }
-    return false;
-}
-static char *flip_store_parse_vgm_firmware(DataLoaderModel *model)
-{
-    UNUSED(model);
-    return "Firmware downloaded successfully";
-}
-static void flip_store_switch_to_vgm_firmware_list(FlipStoreApp *app)
-{
-    flip_store_generic_switch_to_view(app, vgm_firmwares[selected_firmware_index].name, flip_store_fetch_vgm_firmware, flip_store_parse_vgm_firmware, 1, callback_to_vgm_firmware_list, FlipStoreViewLoader);
-}
-
-// Function to draw the message on the canvas with word wrapping
-static void draw_description(Canvas *canvas, const char *description, int x, int y)
-{
-    if (description == NULL || strlen(description) == 0)
-    {
-        FURI_LOG_E(TAG, "User message is NULL.");
-        return;
-    }
-    if (!canvas)
-    {
-        FURI_LOG_E(TAG, "Canvas is NULL.");
-        return;
-    }
-
-    size_t msg_length = strlen(description);
-    size_t start = 0;
-    int line_num = 0;
-    char line[MAX_LINE_LENGTH + 1]; // Buffer for the current line (+1 for null terminator)
-
-    while (start < msg_length && line_num < 4)
-    {
-        size_t remaining = msg_length - start;
-        size_t len = (remaining > MAX_LINE_LENGTH) ? MAX_LINE_LENGTH : remaining;
-
-        if (remaining > MAX_LINE_LENGTH)
-        {
-            // Find the last space within the first 'len' characters
-            size_t last_space = len;
-            while (last_space > 0 && description[start + last_space - 1] != ' ')
-            {
-                last_space--;
-            }
-
-            if (last_space > 0)
-            {
-                len = last_space; // Adjust len to the position of the last space
-            }
-        }
-
-        // Copy the substring to 'line' and null-terminate it
-        memcpy(line, description + start, len);
-        line[len] = '\0'; // Ensure the string is null-terminated
-
-        // Draw the string on the canvas
-        // Adjust the y-coordinate based on the line number
-        canvas_draw_str_aligned(canvas, x, y + line_num * 10, AlignLeft, AlignTop, line);
-
-        // Update the start position for the next line
-        start += len;
-
-        // Skip any spaces to avoid leading spaces on the next line
-        while (start < msg_length && description[start] == ' ')
-        {
-            start++;
-        }
-
-        // Increment the line number
-        line_num++;
-    }
-}
-
-static void flip_store_view_draw_callback_app_list(Canvas *canvas, void *model)
-{
-    UNUSED(model);
-    canvas_clear(canvas);
-    canvas_set_font(canvas, FontPrimary);
-    char title[64];
-    snprintf(title, 64, "%s (v.%s)", flip_catalog[app_selected_index].app_name, flip_catalog[app_selected_index].app_version);
-    canvas_draw_str(canvas, 0, 10, title);
-    canvas_set_font(canvas, FontSecondary);
-    draw_description(canvas, flip_catalog[app_selected_index].app_description, 0, 13);
-    if (flip_store_app_does_exist)
-    {
-        canvas_draw_icon(canvas, 0, 53, &I_ButtonLeft_4x7);
-        canvas_draw_str_aligned(canvas, 7, 54, AlignLeft, AlignTop, "Delete");
-        canvas_draw_icon(canvas, 45, 53, &I_ButtonBACK_10x8);
-        canvas_draw_str_aligned(canvas, 57, 54, AlignLeft, AlignTop, "Back");
-    }
-    else
-    {
-        canvas_draw_icon(canvas, 0, 53, &I_ButtonBACK_10x8);
-        canvas_draw_str_aligned(canvas, 12, 54, AlignLeft, AlignTop, "Back");
-    }
-    canvas_draw_icon(canvas, 90, 53, &I_ButtonRight_4x7);
-    canvas_draw_str_aligned(canvas, 97, 54, AlignLeft, AlignTop, "Install");
-}
-
-static bool flip_store_input_callback(InputEvent *event, void *context)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return false;
-    }
-    if (event->type == InputTypeShort)
-    {
-        if (event->key == InputKeyLeft && flip_store_app_does_exist)
-        {
-            // Left button clicked, delete the app
-            view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewAppDelete);
-            return true;
-        }
-        if (event->key == InputKeyRight)
-        {
-            // Right button clicked, download the app
-            flip_store_dl_app_switch_to_view(app);
-            return true;
-        }
-    }
-    else if (event->type == InputTypePress)
-    {
-        if (event->key == InputKeyBack)
-        {
-            // Back button clicked, switch to the previous view.
-            view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewAppListCategory);
-            return true;
-        }
-    }
-
-    return false;
-}
-static void free_text_input_view(FlipStoreApp *app);
-static bool alloc_text_input_view(void *context, char *title);
-static void flip_store_text_updated_ssid(void *context)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-
-    // store the entered text
-    strncpy(app->uart_text_input_buffer, app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size);
-
-    // Ensure null-termination
-    app->uart_text_input_buffer[app->uart_text_input_buffer_size - 1] = '\0';
-
-    // save the setting
-    save_char("WiFi-SSID", app->uart_text_input_buffer);
-
-    // update the variable item text
-    if (app->variable_item_ssid)
-    {
-        variable_item_set_current_value_text(app->variable_item_ssid, app->uart_text_input_buffer);
-
-        // get value of password
-        char pass[64];
-        if (load_char("WiFi-Password", pass, sizeof(pass)))
-        {
-            if (strlen(pass) > 0 && strlen(app->uart_text_input_buffer) > 0)
-            {
-                // save the settings
-                save_settings(app->uart_text_input_buffer, pass);
-
-                // initialize the http
-                FlipperHTTP *fhttp = flipper_http_alloc();
-                if (fhttp)
-                {
-                    // save the wifi if the device is connected
-                    if (!flipper_http_save_wifi(fhttp, app->uart_text_input_buffer, pass))
-                    {
-                        easy_flipper_dialog("FlipperHTTP Error", "Ensure your WiFi Developer\nBoard or Pico W is connected\nand the latest FlipperHTTP\nfirmware is installed.");
-                    }
-
-                    // free the resources
-                    flipper_http_free(fhttp);
-                }
-                else
-                {
-                    easy_flipper_dialog("FlipperHTTP Error", "The UART is likely busy.\nEnsure you have the correct\nflash for your board then\nrestart your Flipper Zero.");
-                }
-            }
-        }
-    }
-
-    // switch to the settings view
-    view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewSettings);
-}
-static void flip_store_text_updated_pass(void *context)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-
-    // store the entered text
-    strncpy(app->uart_text_input_buffer, app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size);
-
-    // Ensure null-termination
-    app->uart_text_input_buffer[app->uart_text_input_buffer_size - 1] = '\0';
-
-    // save the setting
-    save_char("WiFi-Password", app->uart_text_input_buffer);
-
-    // update the variable item text
-    if (app->variable_item_pass)
-    {
-        // variable_item_set_current_value_text(app->variable_item_pass, app->uart_text_input_buffer);
-    }
-
-    // get value of ssid
-    char ssid[64];
-    if (load_char("WiFi-SSID", ssid, sizeof(ssid)))
-    {
-        if (strlen(ssid) > 0 && strlen(app->uart_text_input_buffer) > 0)
-        {
-            // save the settings
-            save_settings(ssid, app->uart_text_input_buffer);
-
-            // initialize the http
-            FlipperHTTP *fhttp = flipper_http_alloc();
-            if (fhttp)
-            {
-                // save the wifi if the device is connected
-                if (!flipper_http_save_wifi(fhttp, ssid, app->uart_text_input_buffer))
-                {
-                    easy_flipper_dialog("FlipperHTTP Error", "Ensure your WiFi Developer\nBoard or Pico W is connected\nand the latest FlipperHTTP\nfirmware is installed.");
-                }
-
-                // free the resources
-                flipper_http_free(fhttp);
-            }
-            else
-            {
-                easy_flipper_dialog("FlipperHTTP Error", "The UART is likely busy.\nEnsure you have the correct\nflash for your board then\nrestart your Flipper Zero.");
-            }
-        }
-    }
-
-    // switch to the settings view
-    view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewSettings);
-}
-static void flip_store_text_updated_repo(void *context);
-static void flip_store_text_updated_author(void *context)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-
-    // store the entered text
-    strncpy(app->uart_text_input_buffer, app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size);
-
-    // Ensure null-termination
-    app->uart_text_input_buffer[app->uart_text_input_buffer_size - 1] = '\0';
-
-    // save the setting
-    save_char("Github-Author", app->uart_text_input_buffer);
-
-    view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewSubmenu);
-    uart_text_input_reset(app->uart_text_input);
-    uart_text_input_set_header_text(app->uart_text_input, "Repository");
-    app->uart_text_input_buffer_size = 64;
-    free(app->uart_text_input_buffer);
-    free(app->uart_text_input_temp_buffer);
-    easy_flipper_set_buffer(&app->uart_text_input_buffer, app->uart_text_input_buffer_size);
-    easy_flipper_set_buffer(&app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size);
-    uart_text_input_set_result_callback(app->uart_text_input, flip_store_text_updated_repo, app, app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size, false);
-    view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewTextInput);
-}
-
-static bool flip_store_fetch_github(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP is NULL");
-        return false;
-    }
-    char author[64];
-    char repo[64];
-    if (!load_char("Github-Author", author, sizeof(author)) || !load_char("Github-Repo", repo, sizeof(repo)))
-    {
-        FURI_LOG_E(TAG, "Failed to load Github author or repo");
-        return false;
-    }
-    return flip_store_get_github_contents(fhttp, author, repo);
-}
-
-static bool flip_store_parse_github(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP is NULL");
-        return false;
-    }
-    char author[64];
-    char repo[64];
-    if (!load_char("Github-Author", author, sizeof(author)) || !load_char("Github-Repo", repo, sizeof(repo)))
-    {
-        FURI_LOG_E(TAG, "Failed to load Github author or repo");
-        return false;
-    }
-    if (!flip_store_parse_github_contents(fhttp->file_path, author, repo))
-    {
-        return false;
-    }
-    return flip_store_install_all_github_files(fhttp, author, repo);
-}
-static bool github_success = false;
-static void flip_store_get_github_repository(FlipStoreApp *app)
-{
-    FlipperHTTP *fhttp = flipper_http_alloc();
-    if (!fhttp)
-    {
-        FURI_LOG_E(TAG, "Failed to allocate FlipperHTTP");
-        return;
-    }
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-    bool http_request()
-    {
-        github_success = flip_store_fetch_github(fhttp);
-        return github_success;
-    }
-    bool http_parse()
-    {
-        github_success = flip_store_parse_github(fhttp);
-        return github_success;
-    }
-    flipper_http_loading_task(fhttp, http_request, http_parse, FlipStoreViewSubmenuOptions, FlipStoreViewWidgetResult, &app->view_dispatcher);
-    flipper_http_free(fhttp);
-    if (github_success)
-    {
-        easy_flipper_dialog("Success", "Repository downloaded\nsuccessfully.");
-    }
-    else
-    {
-        easy_flipper_dialog("Failure", "Failed to download\nrepository.");
-    }
-}
-static void flip_store_text_updated_repo(void *context)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-
-    // store the entered text
-    strncpy(app->uart_text_input_buffer, app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size);
-
-    // Ensure null-termination
-    app->uart_text_input_buffer[app->uart_text_input_buffer_size - 1] = '\0';
-
-    // save the setting
-    save_char("Github-Repo", app->uart_text_input_buffer);
-    view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewSubmenuOptions);
-    flip_store_get_github_repository(app);
-}
-static void free_category_submenu(FlipStoreApp *app)
-{
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-    if (app->submenu_app_list_category)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewAppListCategory);
-        submenu_free(app->submenu_app_list_category);
-        app->submenu_app_list_category = NULL;
-    }
-}
-static void free_variable_item_list(FlipStoreApp *app);
-
-uint32_t callback_to_submenu(void *context)
-{
-    UNUSED(context);
-    firmware_free();
-    return FlipStoreViewSubmenu;
-}
-
-uint32_t callback_to_firmware_list(void *context)
-{
-    UNUSED(context);
-    return FlipStoreViewFirmwares;
-}
-uint32_t callback_to_vgm_firmware_list(void *context)
-{
-    UNUSED(context);
-    return FlipStoreViewVGMFirmwares;
-}
-static uint32_t callback_to_app_category_list(void *context)
-{
-    UNUSED(context);
-    return FlipStoreViewAppListCategory;
-}
-uint32_t callback_to_app_list(void *context)
-{
-    UNUSED(context);
-    return FlipStoreViewAppList;
-}
-
-static uint32_t callback_to_wifi_settings(void *context)
-{
-    UNUSED(context);
-    return FlipStoreViewSettings;
-}
-static void dialog_firmware_callback(DialogExResult result, void *context)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-    if (result == DialogExResultLeft) // No
-    {
-        // switch to the firmware list
-        if (is_esp32_firmware)
-        {
-            view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewFirmwares);
-        }
-        else
-        {
-            view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewVGMFirmwares);
-        }
-    }
-    else if (result == DialogExResultRight)
-    {
-        // download the firmware then return to the firmware list
-        if (is_esp32_firmware)
-        {
-            flip_store_switch_to_firmware_list(app);
-        }
-        else
-        {
-            flip_store_switch_to_vgm_firmware_list(app);
-        }
-    }
-}
-
-static bool alloc_about_view(FlipStoreApp *app)
-{
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return false;
-    }
-    if (!app->widget_about)
-    {
-        if (!easy_flipper_set_widget(
-                &app->widget_about,
-                FlipStoreViewAbout,
-                "Welcome to the FlipStore!\n------\nDownload apps via WiFi and\nrun them on your Flipper!\n------\nwww.github.com/jblanked",
-                callback_to_submenu,
-                &app->view_dispatcher))
-        {
-            return false;
-        }
-        if (!app->widget_about)
-        {
-            return false;
-        }
-    }
-    return true;
-}
-
-static void free_about_view(FlipStoreApp *app)
-{
-    if (app && app->widget_about != NULL)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewAbout);
-        widget_free(app->widget_about);
-        app->widget_about = NULL;
-    }
-}
-static bool alloc_text_input_view(void *context, char *title)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return false;
-    }
-    if (!title)
-    {
-        FURI_LOG_E(TAG, "Title is NULL");
-        return false;
-    }
-    app->uart_text_input_buffer_size = 64;
-    if (!app->uart_text_input_buffer)
-    {
-        if (!easy_flipper_set_buffer(&app->uart_text_input_buffer, app->uart_text_input_buffer_size))
-        {
-            return false;
-        }
-    }
-    if (!app->uart_text_input_temp_buffer)
-    {
-        if (!easy_flipper_set_buffer(&app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size))
-        {
-            return false;
-        }
-    }
-    if (!app->uart_text_input)
-    {
-        if (strcmp(title, "SSID") != 0 && strcmp(title, "Password") != 0)
-        {
-            // Github repository download
-            if (!easy_flipper_set_uart_text_input(
-                    &app->uart_text_input,
-                    FlipStoreViewTextInput,
-                    title,
-                    app->uart_text_input_temp_buffer,
-                    app->uart_text_input_buffer_size,
-                    strcmp(title, "Author") == 0 ? flip_store_text_updated_author : flip_store_text_updated_repo,
-                    callback_to_submenu_options,
-                    &app->view_dispatcher,
-                    app))
-            {
-                return false;
-            }
-            if (!app->uart_text_input)
-            {
-                return false;
-            }
-        }
-        else
-        {
-            if (!easy_flipper_set_uart_text_input(
-                    &app->uart_text_input,
-                    FlipStoreViewTextInput,
-                    title,
-                    app->uart_text_input_temp_buffer,
-                    app->uart_text_input_buffer_size,
-                    strcmp(title, "SSID") == 0 ? flip_store_text_updated_ssid : flip_store_text_updated_pass,
-                    callback_to_wifi_settings,
-                    &app->view_dispatcher,
-                    app))
-            {
-                return false;
-            }
-            if (!app->uart_text_input)
-            {
-                return false;
-            }
-            char ssid[64];
-            char pass[64];
-            if (load_settings(ssid, sizeof(ssid), pass, sizeof(pass)))
-            {
-                if (strcmp(title, "SSID") == 0)
-                {
-                    strncpy(app->uart_text_input_temp_buffer, ssid, app->uart_text_input_buffer_size);
-                }
-                else
-                {
-                    strncpy(app->uart_text_input_temp_buffer, pass, app->uart_text_input_buffer_size);
-                }
-            }
-        }
-    }
-    return true;
-}
-static void free_text_input_view(FlipStoreApp *app)
-{
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-    if (app->uart_text_input)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewTextInput);
-        uart_text_input_free(app->uart_text_input);
-        app->uart_text_input = NULL;
-    }
-    if (app->uart_text_input_buffer)
-    {
-        free(app->uart_text_input_buffer);
-        app->uart_text_input_buffer = NULL;
-    }
-    if (app->uart_text_input_temp_buffer)
-    {
-        free(app->uart_text_input_temp_buffer);
-        app->uart_text_input_temp_buffer = NULL;
-    }
-}
-static void settings_item_selected(void *context, uint32_t index);
-static bool alloc_variable_item_list(void *context)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return false;
-    }
-    if (!app->variable_item_list)
-    {
-        if (!easy_flipper_set_variable_item_list(&app->variable_item_list, FlipStoreViewSettings, settings_item_selected, callback_to_submenu, &app->view_dispatcher, app))
-            return false;
-
-        if (!app->variable_item_list)
-            return false;
-
-        if (!app->variable_item_ssid)
-        {
-            app->variable_item_ssid = variable_item_list_add(app->variable_item_list, "SSID", 0, NULL, NULL);
-            variable_item_set_current_value_text(app->variable_item_ssid, "");
-        }
-        if (!app->variable_item_pass)
-        {
-            app->variable_item_pass = variable_item_list_add(app->variable_item_list, "Password", 0, NULL, NULL);
-            variable_item_set_current_value_text(app->variable_item_pass, "");
-        }
-        char ssid[64];
-        char pass[64];
-        if (load_settings(ssid, sizeof(ssid), pass, sizeof(pass)))
-        {
-            variable_item_set_current_value_text(app->variable_item_ssid, ssid);
-            // variable_item_set_current_value_text(app->variable_item_pass, pass);
-            save_char("WiFi-SSID", ssid);
-            save_char("WiFi-Password", pass);
-        }
-    }
-    return true;
-}
-static void free_variable_item_list(FlipStoreApp *app)
-{
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-    if (app->variable_item_list)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewSettings);
-        variable_item_list_free(app->variable_item_list);
-        app->variable_item_list = NULL;
-    }
-    if (app->variable_item_ssid)
-    {
-        free(app->variable_item_ssid);
-        app->variable_item_ssid = NULL;
-    }
-    if (app->variable_item_pass)
-    {
-        free(app->variable_item_pass);
-        app->variable_item_pass = NULL;
-    }
-}
-static bool alloc_dialog_firmware(void *context)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return false;
-    }
-
-    if (!app->dialog_firmware)
-    {
-        if (!easy_flipper_set_dialog_ex(
-                &app->dialog_firmware,
-                FlipStoreViewFirmwareDialog,
-                is_esp32_firmware ? "Download ESP32 Firmware" : "Download VGM Firmware",
-                0,
-                0,
-                "Are you sure you want to\ndownload this firmware?",
-                0,
-                10,
-                "No",
-                "Yes",
-                NULL,
-                dialog_firmware_callback,
-                callback_to_firmware_list,
-                &app->view_dispatcher,
-                app))
-        {
-            return false;
-        }
-        if (!app->dialog_firmware)
-        {
-            return false;
-        }
-        if (is_esp32_firmware)
-        {
-            dialog_ex_set_header(app->dialog_firmware, firmwares[selected_firmware_index].name, 0, 0, AlignLeft, AlignTop);
-        }
-        else
-        {
-            dialog_ex_set_header(app->dialog_firmware, vgm_firmwares[selected_firmware_index].name, 0, 0, AlignLeft, AlignTop);
-        }
-    }
-    return true;
-}
-static void free_dialog_firmware(FlipStoreApp *app)
-{
-    if (app && app->dialog_firmware)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewFirmwareDialog);
-        dialog_ex_free(app->dialog_firmware);
-        app->dialog_firmware = NULL;
-    }
-}
-static bool alloc_app_info_view(FlipStoreApp *app)
-{
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return false;
-    }
-    if (!app->view_app_info)
-    {
-        if (!easy_flipper_set_view(
-                &app->view_app_info,
-                FlipStoreViewAppInfo,
-                flip_store_view_draw_callback_app_list,
-                flip_store_input_callback,
-                callback_to_app_category_list,
-                &app->view_dispatcher,
-                app))
-        {
-            return false;
-        }
-        if (!app->view_app_info)
-        {
-            return false;
-        }
-    }
-    return true;
-}
-static void free_app_info_view(FlipStoreApp *app)
-{
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-    if (app->view_app_info)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewAppInfo);
-        view_free(app->view_app_info);
-        app->view_app_info = NULL;
-    }
-}
-uint32_t callback_to_submenu_options(void *context)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return FlipStoreViewSubmenuOptions;
-    }
-    firmware_free();
-    vgm_firmware_free();
-    flip_catalog_free();
-    free_category_submenu(app);
-    return FlipStoreViewSubmenuOptions;
-}
-void free_all_views(FlipStoreApp *app, bool should_free_variable_item_list)
-{
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-    free_about_view(app);
-    flip_catalog_free();
-    if (should_free_variable_item_list)
-    {
-        free_variable_item_list(app);
-    }
-    free_category_submenu(app);
-    free_text_input_view(app);
-    free_dialog_firmware(app);
-    free_app_info_view(app);
-    firmware_free();
-    vgm_firmware_free();
-}
-uint32_t callback_exit_app(void *context)
-{
-    UNUSED(context);
-    return VIEW_NONE; // Return VIEW_NONE to exit the app
-}
-
-static bool set_appropriate_list(FlipperHTTP *fhttp, FlipStoreApp *app)
-{
-    if (!fhttp || !app)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP oor app is NULL");
-        return false;
-    }
-
-    if (!easy_flipper_set_submenu(&app->submenu_app_list_category, FlipStoreViewAppListCategory, categories[flip_store_category_index], callback_to_app_list, &app->view_dispatcher))
-    {
-        FURI_LOG_E(TAG, "Failed to set submenu");
-        return false;
-    }
-
-    if (flip_store_process_app_list(fhttp) && app->submenu_app_list_category && flip_catalog)
-    {
-        submenu_reset(app->submenu_app_list_category);
-        submenu_set_header(app->submenu_app_list_category, categories[flip_store_category_index]);
-        // add each app name to submenu
-        for (size_t i = 0; i < flip_catalog->count; i++)
-        {
-            if (strlen(flip_catalog[i].app_name) > 0)
-            {
-                submenu_add_item(app->submenu_app_list_category, flip_catalog[i].app_name, FlipStoreSubmenuIndexStartAppList + i, callback_submenu_choices, app);
-            }
-            else
-            {
-                break;
-            }
-        }
-        // add [LOAD NEXT] to submenu
-        submenu_add_item(app->submenu_app_list_category, "[LOAD NEXT]", FlipStoreSubmenuIndexStartAppList + flip_catalog->count, callback_submenu_choices, app);
-        return true;
-    }
-    FURI_LOG_E(TAG, "Failed to process the app list");
-    return false;
-}
-
-// we'll have to loop 8 at a time due to memory constraints
-static void fetch_appropiate_app_list(FlipStoreApp *app, int iteration)
-{
-    FlipperHTTP *fhttp = flipper_http_alloc();
-    if (!fhttp)
-    {
-        FURI_LOG_E(TAG, "Failed to allocate FlipperHTTP");
-        return;
-    }
-    bool fetch_app_list()
-    {
-        // ensure /apps_data/flip_store/data exists
-        Storage *storage = furi_record_open(RECORD_STORAGE);
-        char dir[256];
-        snprintf(dir, sizeof(dir), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data");
-        storage_common_mkdir(storage, dir);
-        furi_record_close(RECORD_STORAGE);
-        fhttp->state = IDLE;
-        flip_catalog_free();
-        snprintf(
-            fhttp->file_path,
-            sizeof(fhttp->file_path),
-            STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data/%s.json", categories[flip_store_category_index]);
-        fhttp->save_received_data = true;
-        fhttp->is_bytes_request = false;
-        char url[256];
-        // load 8 at a time
-        snprintf(url, sizeof(url), "https://catalog.flipperzero.one/api/v0/0/application?limit=8&is_latest_release_version=true&offset=%d&sort_by=updated_at&sort_order=-1&category_id=%s", iteration, category_ids[flip_store_category_index]);
-        return flipper_http_get_request_with_headers(fhttp, url, "{\"Content-Type\":\"application/json\"}");
-    }
-    bool parse_app_list()
-    {
-        return set_appropriate_list(fhttp, app);
-    }
-    flipper_http_loading_task(fhttp, fetch_app_list, parse_app_list, FlipStoreViewAppListCategory, FlipStoreViewSubmenuOptions, &app->view_dispatcher);
-    flipper_http_free(fhttp);
-}
-
-void callback_submenu_choices(void *context, uint32_t index)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-
-    switch (index)
-    {
-    case FlipStoreSubmenuIndexAbout:
-        free_all_views(app, true);
-        if (!alloc_about_view(app))
-        {
-            FURI_LOG_E(TAG, "Failed to set about view");
-            return;
-        }
-        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewAbout);
-        break;
-    case FlipStoreSubmenuIndexSettings:
-        free_all_views(app, true);
-        if (!alloc_variable_item_list(app))
-        {
-            FURI_LOG_E(TAG, "Failed to allocate variable item list");
-            return;
-        }
-        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewSettings);
-        break;
-    case FlipStoreSubmenuIndexOptions:
-        free_all_views(app, true);
-        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewSubmenuOptions);
-        break;
-    case FlipStoreSubmenuIndexAppList:
-        flip_store_category_index = 0;
-        flip_store_app_does_exist = false;
-        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewAppList);
-        break;
-    case FlipStoreSubmenuIndexFirmwares: // esp32 firmwares
-        firmwares = firmware_alloc();
-        if (firmwares == NULL)
-        {
-            FURI_LOG_E(TAG, "Failed to allocate memory for firmwares");
-            return;
-        }
-        submenu_reset(app->submenu_firmwares);
-        submenu_set_header(app->submenu_firmwares, "ESP32 Firmwares");
-        for (int i = 0; i < FIRMWARE_COUNT; i++)
-        {
-            submenu_add_item(app->submenu_firmwares, firmwares[i].name, FlipStoreSubmenuIndexStartFirmwares + i, callback_submenu_choices, app);
-        }
-        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewFirmwares);
-        break;
-    case FlipStoreSubmenuIndexVGMFirmwares: // vgm firmwares
-        vgm_firmwares = vgm_firmware_alloc();
-        if (vgm_firmwares == NULL)
-        {
-            FURI_LOG_E(TAG, "Failed to allocate memory for vgm firmwares");
-            return;
-        }
-        submenu_reset(app->submenu_vgm_firmwares);
-        submenu_set_header(app->submenu_vgm_firmwares, "VGM Firmwares");
-        for (int i = 0; i < VGM_FIRMWARE_COUNT; i++)
-        {
-            submenu_add_item(app->submenu_vgm_firmwares, vgm_firmwares[i].name, FlipStoreSubmenuIndexStartVGMFirmwares + i, callback_submenu_choices, app);
-        }
-        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewVGMFirmwares);
-        break;
-    case FlipStoreSubmenuIndexGitHub: // github
-        free_all_views(app, true);
-        if (!alloc_text_input_view(app, "Author"))
-        {
-            FURI_LOG_E(TAG, "Failed to allocate text input view");
-            return;
-        }
-        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewTextInput);
-        break;
-    case FlipStoreSubmenuIndexAppListBluetooth:
-        free_all_views(app, true);
-        flip_store_category_index = 0;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    case FlipStoreSubmenuIndexAppListGames:
-        free_all_views(app, true);
-        flip_store_category_index = 1;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    case FlipStoreSubmenuIndexAppListGPIO:
-        free_all_views(app, true);
-        flip_store_category_index = 2;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    case FlipStoreSubmenuIndexAppListInfrared:
-        free_all_views(app, true);
-        flip_store_category_index = 3;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    case FlipStoreSubmenuIndexAppListiButton:
-        free_all_views(app, true);
-        flip_store_category_index = 4;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    case FlipStoreSubmenuIndexAppListMedia:
-        free_all_views(app, true);
-        flip_store_category_index = 5;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    case FlipStoreSubmenuIndexAppListNFC:
-        free_all_views(app, true);
-        flip_store_category_index = 6;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    case FlipStoreSubmenuIndexAppListRFID:
-        free_all_views(app, true);
-        flip_store_category_index = 7;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    case FlipStoreSubmenuIndexAppListSubGHz:
-        free_all_views(app, true);
-        flip_store_category_index = 8;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    case FlipStoreSubmenuIndexAppListTools:
-        free_all_views(app, true);
-        flip_store_category_index = 9;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    case FlipStoreSubmenuIndexAppListUSB:
-        free_all_views(app, true);
-        flip_store_category_index = 10;
-        flip_store_app_does_exist = false;
-        fetch_appropiate_app_list(app, 0);
-        break;
-    default:
-        // Check if the index is within the ESP32 firmwares list range
-        if (index >= FlipStoreSubmenuIndexStartFirmwares && index < FlipStoreSubmenuIndexStartFirmwares + FIRMWARE_COUNT)
-        {
-            // Get the firmware index
-            uint32_t firmware_index = index - FlipStoreSubmenuIndexStartFirmwares;
-
-            // Check if the firmware index is valid
-            if ((int)firmware_index >= 0 && firmware_index < FIRMWARE_COUNT)
-            {
-                // Get the firmware name
-                selected_firmware_index = firmware_index;
-                is_esp32_firmware = true;
-
-                // Switch to the firmware download view
-                free_dialog_firmware(app);
-                if (!alloc_dialog_firmware(app))
-                {
-                    FURI_LOG_E(TAG, "Failed to allocate dialog firmware");
-                    return;
-                }
-                view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewFirmwareDialog);
-            }
-            else
-            {
-                FURI_LOG_E(TAG, "Invalid firmware index");
-                easy_flipper_dialog("Error", "Issue parsing firmware.");
-            }
-        }
-        // Check if the index is within the VGM firmwares list range
-        else if (index >= FlipStoreSubmenuIndexStartVGMFirmwares && index < FlipStoreSubmenuIndexStartVGMFirmwares + VGM_FIRMWARE_COUNT)
-        {
-            // Get the firmware index
-            uint32_t firmware_index = index - FlipStoreSubmenuIndexStartVGMFirmwares;
-
-            // Check if the firmware index is valid
-            if ((int)firmware_index >= 0 && firmware_index < VGM_FIRMWARE_COUNT)
-            {
-                // Get the firmware name
-                selected_firmware_index = firmware_index;
-                is_esp32_firmware = false;
-
-                // Switch to the firmware download view
-                free_dialog_firmware(app);
-                if (!alloc_dialog_firmware(app))
-                {
-                    FURI_LOG_E(TAG, "Failed to allocate dialog firmware");
-                    return;
-                }
-                view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewFirmwareDialog);
-            }
-            else
-            {
-                FURI_LOG_E(TAG, "Invalid firmware index");
-                easy_flipper_dialog("Error", "Issue parsing firmware.");
-            }
-        }
-        // Check if the index is within the app list range
-        else if (index >= FlipStoreSubmenuIndexStartAppList && index < FlipStoreSubmenuIndexStartAppList + flip_catalog->count)
-        {
-            // Get the app index
-            uint32_t app_index = index - FlipStoreSubmenuIndexStartAppList;
-
-            // Check if the app index is valid
-            if ((int)app_index >= 0 && app_index < flip_catalog->count)
-            {
-                // Get the app name
-                char *app_name = flip_catalog[app_index].app_name;
-
-                // Check if the app name is valid
-                if (app_name != NULL && strlen(app_name) > 0)
-                {
-                    app_selected_index = app_index;
-                    flip_store_app_does_exist = app_exists(flip_catalog[app_selected_index].app_id, categories[flip_store_category_index]);
-                    free_app_info_view(app);
-                    if (!alloc_app_info_view(app))
-                    {
-                        FURI_LOG_E(TAG, "Failed to allocate app info view");
-                        return;
-                    }
-                    view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewAppInfo);
-                }
-                else
-                {
-                    FURI_LOG_E(TAG, "Invalid app name");
-                }
-            }
-            else
-            {
-                FURI_LOG_E(TAG, "Invalid app index");
-            }
-        }
-        // Check if the index is for loading the next set of apps
-        else if (index == FlipStoreSubmenuIndexStartAppList + flip_catalog->count)
-        {
-            catalog_iteration = flip_catalog->iteration + 8;
-            view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewWidgetResult);
-            free_category_submenu(app);
-            flip_catalog_free();
-            fetch_appropiate_app_list(app, catalog_iteration);
-        }
-        else
-        {
-            FURI_LOG_E(TAG, "Unknown submenu index");
-        }
-        break;
-    }
-}
-
-static void settings_item_selected(void *context, uint32_t index)
-{
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-    char ssid[64];
-    char pass[64];
-    switch (index)
-    {
-    case 0: // Input SSID
-        // Text Input
-        free_all_views(app, false);
-        if (!alloc_text_input_view(app, "SSID"))
-        {
-            FURI_LOG_E(TAG, "Failed to allocate text input view");
-            return;
-        }
-        // load SSID
-        if (load_settings(ssid, sizeof(ssid), pass, sizeof(pass)))
-        {
-            strncpy(app->uart_text_input_temp_buffer, ssid, app->uart_text_input_buffer_size - 1);
-            app->uart_text_input_temp_buffer[app->uart_text_input_buffer_size - 1] = '\0';
-        }
-        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewTextInput);
-        break;
-    case 1: // Input Password
-        free_all_views(app, false);
-        if (!alloc_text_input_view(app, "Password"))
-        {
-            FURI_LOG_E(TAG, "Failed to allocate text input view");
-            return;
-        }
-        // load password
-        if (load_settings(ssid, sizeof(ssid), pass, sizeof(pass)))
-        {
-            strncpy(app->uart_text_input_temp_buffer, pass, app->uart_text_input_buffer_size - 1);
-            app->uart_text_input_temp_buffer[app->uart_text_input_buffer_size - 1] = '\0';
-        }
-        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewTextInput);
-        break;
-    default:
-        FURI_LOG_E(TAG, "Unknown configuration item index");
-        break;
-    }
-}
-
-static void flip_store_widget_set_text(char *message, Widget **widget)
-{
-    if (widget == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_set_widget_text - widget is NULL");
-        DEV_CRASH();
-        return;
-    }
-    if (message == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_set_widget_text - message is NULL");
-        DEV_CRASH();
-        return;
-    }
-    widget_reset(*widget);
-
-    uint32_t message_length = strlen(message); // Length of the message
-    uint32_t i = 0;                            // Index tracker
-    uint32_t formatted_index = 0;              // Tracker for where we are in the formatted message
-    char *formatted_message;                   // Buffer to hold the final formatted message
-
-    // Allocate buffer with double the message length plus one for safety
-    if (!easy_flipper_set_buffer(&formatted_message, message_length * 2 + 1))
-    {
-        return;
-    }
-
-    while (i < message_length)
-    {
-        uint32_t max_line_length = 31;                  // Maximum characters per line
-        uint32_t remaining_length = message_length - i; // Remaining characters
-        uint32_t line_length = (remaining_length < max_line_length) ? remaining_length : max_line_length;
-
-        // Check for newline character within the current segment
-        uint32_t newline_pos = i;
-        bool found_newline = false;
-        for (; newline_pos < i + line_length && newline_pos < message_length; newline_pos++)
-        {
-            if (message[newline_pos] == '\n')
-            {
-                found_newline = true;
-                break;
-            }
-        }
-
-        if (found_newline)
-        {
-            // If newline found, set line_length up to the newline
-            line_length = newline_pos - i;
-        }
-
-        // Temporary buffer to hold the current line
-        char line[32];
-        strncpy(line, message + i, line_length);
-        line[line_length] = '\0';
-
-        // If newline was found, skip it for the next iteration
-        if (found_newline)
-        {
-            i += line_length + 1; // +1 to skip the '\n' character
-        }
-        else
-        {
-            // Check if the line ends in the middle of a word and adjust accordingly
-            if (line_length == max_line_length && message[i + line_length] != '\0' && message[i + line_length] != ' ')
-            {
-                // Find the last space within the current line to avoid breaking a word
-                char *last_space = strrchr(line, ' ');
-                if (last_space != NULL)
-                {
-                    // Adjust the line_length to avoid cutting the word
-                    line_length = last_space - line;
-                    line[line_length] = '\0'; // Null-terminate at the space
-                }
-            }
-
-            // Move the index forward by the determined line_length
-            i += line_length;
-
-            // Skip any spaces at the beginning of the next line
-            while (i < message_length && message[i] == ' ')
-            {
-                i++;
-            }
-        }
-
-        // Manually copy the fixed line into the formatted_message buffer
-        for (uint32_t j = 0; j < line_length; j++)
-        {
-            formatted_message[formatted_index++] = line[j];
-        }
-
-        // Add a newline character for line spacing
-        formatted_message[formatted_index++] = '\n';
-    }
-
-    // Null-terminate the formatted_message
-    formatted_message[formatted_index] = '\0';
-
-    // Add the formatted message to the widget
-    widget_add_text_scroll_element(*widget, 0, 0, 128, 64, formatted_message);
-}
-static void flip_store_request_error(Canvas *canvas, FlipperHTTP *fhttp)
-{
-    if (!canvas)
-    {
-        FURI_LOG_E(TAG, "Canvas is NULL");
-        return;
-    }
-    if (!fhttp)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP is NULL");
-        return;
-    }
-    if (fhttp->last_response != NULL)
-    {
-        if (strstr(fhttp->last_response, "[ERROR] Not connected to Wifi. Failed to reconnect.") != NULL)
-        {
-            canvas_clear(canvas);
-            canvas_draw_str(canvas, 0, 10, "[ERROR] Not connected to Wifi.");
-            canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
-            canvas_draw_str(canvas, 0, 60, "Press BACK to return.");
-        }
-        else if (strstr(fhttp->last_response, "[ERROR] Failed to connect to Wifi.") != NULL)
-        {
-            canvas_clear(canvas);
-            canvas_draw_str(canvas, 0, 10, "[ERROR] Not connected to Wifi.");
-            canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
-            canvas_draw_str(canvas, 0, 60, "Press BACK to return.");
-        }
-        else
-        {
-            FURI_LOG_E(TAG, "Received an error: %s", fhttp->last_response);
-            canvas_draw_str(canvas, 0, 42, "Unusual error...");
-            canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
-            canvas_draw_str(canvas, 0, 60, "Press BACK to return.");
-        }
-    }
-    else
-    {
-        canvas_clear(canvas);
-        canvas_draw_str(canvas, 0, 10, "[ERROR] Unknown error.");
-        canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
-        canvas_draw_str(canvas, 0, 60, "Press BACK to return.");
-    }
-}
-
-void flip_store_loader_draw_callback(Canvas *canvas, void *model)
-{
-    if (!canvas || !model)
-    {
-        FURI_LOG_E(TAG, "flip_store_loader_draw_callback - canvas or model is NULL");
-        return;
-    }
-
-    DataLoaderModel *data_loader_model = (DataLoaderModel *)model;
-    SerialState http_state = data_loader_model->fhttp->state;
-    DataState data_state = data_loader_model->data_state;
-    char *title = data_loader_model->title;
-
-    canvas_set_font(canvas, FontSecondary);
-
-    if (http_state == INACTIVE)
-    {
-        canvas_draw_str(canvas, 0, 7, "Wifi Dev Board disconnected.");
-        canvas_draw_str(canvas, 0, 17, "Please connect to the board.");
-        canvas_draw_str(canvas, 0, 32, "If your board is connected,");
-        canvas_draw_str(canvas, 0, 42, "make sure you have flashed");
-        canvas_draw_str(canvas, 0, 52, "your WiFi Devboard with the");
-        canvas_draw_str(canvas, 0, 62, "latest FlipperHTTP flash.");
-        return;
-    }
-
-    if (data_state == DataStateError || data_state == DataStateParseError)
-    {
-        flip_store_request_error(canvas, data_loader_model->fhttp);
-        return;
-    }
-
-    canvas_draw_str(canvas, 0, 7, title);
-    canvas_draw_str(canvas, 0, 17, "Loading...");
-
-    if (data_state == DataStateInitial)
-    {
-        return;
-    }
-
-    if (http_state == SENDING)
-    {
-        canvas_draw_str(canvas, 0, 27, "Fetching...");
-        return;
-    }
-
-    if (http_state == RECEIVING || data_state == DataStateRequested)
-    {
-        canvas_draw_str(canvas, 0, 27, "Receiving...");
-        return;
-    }
-
-    if (http_state == IDLE && data_state == DataStateReceived)
-    {
-        canvas_draw_str(canvas, 0, 27, "Processing...");
-        return;
-    }
-
-    if (http_state == IDLE && data_state == DataStateParsed)
-    {
-        canvas_draw_str(canvas, 0, 27, "Processed...");
-        return;
-    }
-}
-
-static void flip_store_loader_process_callback(void *context)
-{
-    if (context == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_loader_process_callback - context is NULL");
-        DEV_CRASH();
-        return;
-    }
-
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    View *view = app->view_loader;
-
-    DataState current_data_state;
-    DataLoaderModel *loader_model = NULL;
-    with_view_model(view, DataLoaderModel * model, { current_data_state = model->data_state; loader_model = model; }, false);
-    if (!loader_model || !loader_model->fhttp)
-    {
-        FURI_LOG_E(TAG, "Model or fhttp is NULL");
-        DEV_CRASH();
-        return;
-    }
-
-    if (current_data_state == DataStateInitial)
-    {
-        with_view_model(
-            view,
-            DataLoaderModel * model,
-            {
-                model->data_state = DataStateRequested;
-                DataLoaderFetch fetch = model->fetcher;
-                if (fetch == NULL)
-                {
-                    FURI_LOG_E(TAG, "Model doesn't have Fetch function assigned.");
-                    model->data_state = DataStateError;
-                    return;
-                }
-
-                // Clear any previous responses
-                strncpy(model->fhttp->last_response, "", 1);
-                bool request_status = fetch(model);
-                if (!request_status)
-                {
-                    model->data_state = DataStateError;
-                }
-            },
-            true);
-    }
-    else if (current_data_state == DataStateRequested || current_data_state == DataStateError)
-    {
-        if (loader_model->fhttp->state == IDLE && loader_model->fhttp->last_response != NULL)
-        {
-            if (strstr(loader_model->fhttp->last_response, "[PONG]") != NULL)
-            {
-                FURI_LOG_DEV(TAG, "PONG received.");
-            }
-            else if (strncmp(loader_model->fhttp->last_response, "[SUCCESS]", 9) == 0)
-            {
-                FURI_LOG_DEV(TAG, "SUCCESS received. %s", loader_model->fhttp->last_response ? loader_model->fhttp->last_response : "NULL");
-            }
-            else if (strncmp(loader_model->fhttp->last_response, "[ERROR]", 9) == 0)
-            {
-                FURI_LOG_DEV(TAG, "ERROR received. %s", loader_model->fhttp->last_response ? loader_model->fhttp->last_response : "NULL");
-            }
-            else if (strlen(loader_model->fhttp->last_response) == 0)
-            {
-                // Still waiting on response
-            }
-            else
-            {
-                with_view_model(view, DataLoaderModel * model, { model->data_state = DataStateReceived; }, true);
-            }
-        }
-        else if (loader_model->fhttp->state == SENDING || loader_model->fhttp->state == RECEIVING)
-        {
-            // continue waiting
-        }
-        else if (loader_model->fhttp->state == INACTIVE)
-        {
-            // inactive. try again
-        }
-        else if (loader_model->fhttp->state == ISSUE)
-        {
-            with_view_model(view, DataLoaderModel * model, { model->data_state = DataStateError; }, true);
-        }
-        else
-        {
-            FURI_LOG_DEV(TAG, "Unexpected state: %d lastresp: %s", loader_model->fhttp->state, loader_model->fhttp->last_response ? loader_model->fhttp->last_response : "NULL");
-            DEV_CRASH();
-        }
-    }
-    else if (current_data_state == DataStateReceived)
-    {
-        with_view_model(
-            view,
-            DataLoaderModel * model,
-            {
-                char *data_text;
-                if (model->parser == NULL)
-                {
-                    data_text = NULL;
-                    FURI_LOG_DEV(TAG, "Parser is NULL");
-                    DEV_CRASH();
-                }
-                else
-                {
-                    data_text = model->parser(model);
-                }
-                FURI_LOG_DEV(TAG, "Parsed data: %s\r\ntext: %s", model->fhttp->last_response ? model->fhttp->last_response : "NULL", data_text ? data_text : "NULL");
-                model->data_text = data_text;
-                if (data_text == NULL)
-                {
-                    model->data_state = DataStateParseError;
-                }
-                else
-                {
-                    model->data_state = DataStateParsed;
-                }
-            },
-            true);
-    }
-    else if (current_data_state == DataStateParsed)
-    {
-        with_view_model(
-            view,
-            DataLoaderModel * model,
-            {
-                if (++model->request_index < model->request_count)
-                {
-                    model->data_state = DataStateInitial;
-                }
-                else
-                {
-                    flip_store_widget_set_text(model->data_text != NULL ? model->data_text : "", &app->widget_result);
-                    if (model->data_text != NULL)
-                    {
-                        free(model->data_text);
-                        model->data_text = NULL;
-                    }
-                    view_set_previous_callback(widget_get_view(app->widget_result), model->back_callback);
-                    view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewWidgetResult);
-                }
-            },
-            true);
-    }
-}
-
-static void flip_store_loader_timer_callback(void *context)
-{
-    if (context == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_loader_timer_callback - context is NULL");
-        DEV_CRASH();
-        return;
-    }
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    view_dispatcher_send_custom_event(app->view_dispatcher, FlipStoreCustomEventProcess);
-}
-
-static void flip_store_loader_on_enter(void *context)
-{
-    if (context == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_loader_on_enter - context is NULL");
-        DEV_CRASH();
-        return;
-    }
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    View *view = app->view_loader;
-    with_view_model(
-        view,
-        DataLoaderModel * model,
-        {
-            view_set_previous_callback(view, model->back_callback);
-            if (model->timer == NULL)
-            {
-                model->timer = furi_timer_alloc(flip_store_loader_timer_callback, FuriTimerTypePeriodic, app);
-            }
-            furi_timer_start(model->timer, 250);
-        },
-        true);
-}
-
-static void flip_store_loader_on_exit(void *context)
-{
-    if (context == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_loader_on_exit - context is NULL");
-        DEV_CRASH();
-        return;
-    }
-    FlipStoreApp *app = (FlipStoreApp *)context;
-    View *view = app->view_loader;
-    with_view_model(
-        view,
-        DataLoaderModel * model,
-        {
-            if (model->timer)
-            {
-                furi_timer_stop(model->timer);
-            }
-        },
-        false);
-}
-
-void flip_store_loader_init(View *view)
-{
-    if (view == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_loader_init - view is NULL");
-        DEV_CRASH();
-        return;
-    }
-    view_allocate_model(view, ViewModelTypeLocking, sizeof(DataLoaderModel));
-    view_set_enter_callback(view, flip_store_loader_on_enter);
-    view_set_exit_callback(view, flip_store_loader_on_exit);
-}
-
-void flip_store_loader_free_model(View *view)
-{
-    if (view == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_loader_free_model - view is NULL");
-        DEV_CRASH();
-        return;
-    }
-    with_view_model(
-        view,
-        DataLoaderModel * model,
-        {
-            if (model->timer)
-            {
-                furi_timer_free(model->timer);
-                model->timer = NULL;
-            }
-            if (model->parser_context)
-            {
-                // do not free the context here, it is the app context
-                // free(model->parser_context);
-                // model->parser_context = NULL;
-            }
-            if (model->fhttp)
-            {
-                flipper_http_free(model->fhttp);
-                model->fhttp = NULL;
-            }
-        },
-        false);
-}
-
-bool flip_store_custom_event_callback(void *context, uint32_t index)
-{
-    if (context == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_custom_event_callback - context is NULL");
-        DEV_CRASH();
-        return false;
-    }
-
-    switch (index)
-    {
-    case FlipStoreCustomEventProcess:
-        flip_store_loader_process_callback(context);
-        return true;
-    default:
-        FURI_LOG_DEV(TAG, "flip_store_custom_event_callback. Unknown index: %ld", index);
-        return false;
-    }
-}
-
-void flip_store_generic_switch_to_view(FlipStoreApp *app, char *title, DataLoaderFetch fetcher, DataLoaderParser parser, size_t request_count, ViewNavigationCallback back, uint32_t view_id)
-{
-    if (app == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_generic_switch_to_view - app is NULL");
-        DEV_CRASH();
-        return;
-    }
-
-    View *view = app->view_loader;
-    if (view == NULL)
-    {
-        FURI_LOG_E(TAG, "flip_store_generic_switch_to_view - view is NULL");
-        DEV_CRASH();
-        return;
-    }
-
-    with_view_model(
-        view,
-        DataLoaderModel * model,
-        {
-            model->title = title;
-            model->fetcher = fetcher;
-            model->parser = parser;
-            model->request_index = 0;
-            model->request_count = request_count;
-            model->back_callback = back;
-            model->data_state = DataStateInitial;
-            model->data_text = NULL;
-            //
-            model->parser_context = app;
-            if (!model->fhttp)
-            {
-                model->fhttp = flipper_http_alloc();
-            }
-        },
-        true);
-
-    view_dispatcher_switch_to_view(app->view_dispatcher, view_id);
-}

+ 0 - 77
callback/flip_store_callback.h

@@ -1,77 +0,0 @@
-#ifndef FLIP_STORE_CALLBACK_H
-#define FLIP_STORE_CALLBACK_H
-#include <flip_store.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <stdbool.h>
-#include <apps/flip_store_apps.h>
-#include <firmwares/flip_store_firmwares.h>
-#include <flip_storage/flip_store_storage.h>
-
-#define MAX_LINE_LENGTH 30
-
-extern bool flip_store_app_does_exist;
-extern uint32_t selected_firmware_index;
-
-uint32_t callback_to_submenu(void *context);
-
-uint32_t callback_to_submenu_options(void *context);
-
-uint32_t callback_to_firmware_list(void *context);
-uint32_t callback_to_vgm_firmware_list(void *context);
-
-uint32_t callback_to_app_list(void *context);
-
-uint32_t callback_exit_app(void *context);
-void callback_submenu_choices(void *context, uint32_t index);
-
-void free_all_views(FlipStoreApp *app, bool should_free_variable_item_list);
-
-// Add edits by Derek Jamison
-typedef enum DataState DataState;
-enum DataState
-{
-    DataStateInitial,
-    DataStateRequested,
-    DataStateReceived,
-    DataStateParsed,
-    DataStateParseError,
-    DataStateError,
-};
-
-typedef enum FlipStoreCustomEvent FlipStoreCustomEvent;
-enum FlipStoreCustomEvent
-{
-    FlipStoreCustomEventProcess,
-};
-
-typedef struct DataLoaderModel DataLoaderModel;
-typedef bool (*DataLoaderFetch)(DataLoaderModel *model);
-typedef char *(*DataLoaderParser)(DataLoaderModel *model);
-struct DataLoaderModel
-{
-    char *title;
-    char *data_text;
-    DataState data_state;
-    DataLoaderFetch fetcher;
-    DataLoaderParser parser;
-    void *parser_context;
-    size_t request_index;
-    size_t request_count;
-    ViewNavigationCallback back_callback;
-    FuriTimer *timer;
-    FlipperHTTP *fhttp;
-};
-void flip_store_generic_switch_to_view(FlipStoreApp *app, char *title, DataLoaderFetch fetcher, DataLoaderParser parser, size_t request_count, ViewNavigationCallback back, uint32_t view_id);
-
-void flip_store_loader_draw_callback(Canvas *canvas, void *model);
-
-void flip_store_loader_init(View *view);
-
-void flip_store_loader_free_model(View *view);
-
-bool flip_store_custom_event_callback(void *context, uint32_t index);
-
-#endif // FLIP_STORE_CALLBACK_H

+ 0 - 590
easy_flipper/easy_flipper.c

@@ -1,590 +0,0 @@
-#include <easy_flipper/easy_flipper.h>
-
-void easy_flipper_dialog(
-    char *header,
-    char *text)
-{
-    DialogsApp *dialogs = furi_record_open(RECORD_DIALOGS);
-    DialogMessage *message = dialog_message_alloc();
-    dialog_message_set_header(
-        message, header, 64, 0, AlignCenter, AlignTop);
-    dialog_message_set_text(
-        message,
-        text,
-        0,
-        63,
-        AlignLeft,
-        AlignBottom);
-    dialog_message_show(dialogs, message);
-    dialog_message_free(message);
-    furi_record_close(RECORD_DIALOGS);
-}
-
-/**
- * @brief Navigation callback for exiting the application
- * @param context The context - unused
- * @return next view id (VIEW_NONE to exit the app)
- */
-uint32_t easy_flipper_callback_exit_app(void *context)
-{
-    // Exit the application
-    if (!context)
-    {
-        FURI_LOG_E(EASY_TAG, "Context is NULL");
-        return VIEW_NONE;
-    }
-    UNUSED(context);
-    return VIEW_NONE; // Return VIEW_NONE to exit the app
-}
-
-/**
- * @brief Initialize a buffer
- * @param buffer The buffer to initialize
- * @param buffer_size The size of the buffer
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_buffer(char **buffer, uint32_t buffer_size)
-{
-    if (!buffer)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_buffer");
-        return false;
-    }
-    *buffer = (char *)malloc(buffer_size);
-    if (!*buffer)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate buffer");
-        return false;
-    }
-    *buffer[0] = '\0';
-    return true;
-}
-
-/**
- * @brief Initialize a View object
- * @param view The View object to initialize
- * @param view_id The ID/Index of the view
- * @param draw_callback The draw callback function (set to NULL if not needed)
- * @param input_callback The input callback function (set to NULL if not needed)
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_view(
-    View **view,
-    int32_t view_id,
-    void draw_callback(Canvas *, void *),
-    bool input_callback(InputEvent *, void *),
-    uint32_t (*previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context)
-{
-    if (!view || !view_dispatcher)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_view");
-        return false;
-    }
-    *view = view_alloc();
-    if (!*view)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate View");
-        return false;
-    }
-    if (draw_callback)
-    {
-        view_set_draw_callback(*view, draw_callback);
-    }
-    if (input_callback)
-    {
-        view_set_input_callback(*view, input_callback);
-    }
-    if (context)
-    {
-        view_set_context(*view, context);
-    }
-    if (previous_callback)
-    {
-        view_set_previous_callback(*view, previous_callback);
-    }
-    view_dispatcher_add_view(*view_dispatcher, view_id, *view);
-    return true;
-}
-
-/**
- * @brief Initialize a ViewDispatcher object
- * @param view_dispatcher The ViewDispatcher object to initialize
- * @param gui The GUI object
- * @param context The context to pass to the event callback
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_view_dispatcher(ViewDispatcher **view_dispatcher, Gui *gui, void *context)
-{
-    if (!view_dispatcher)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_view_dispatcher");
-        return false;
-    }
-    *view_dispatcher = view_dispatcher_alloc();
-    if (!*view_dispatcher)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate ViewDispatcher");
-        return false;
-    }
-    view_dispatcher_attach_to_gui(*view_dispatcher, gui, ViewDispatcherTypeFullscreen);
-    if (context)
-    {
-        view_dispatcher_set_event_callback_context(*view_dispatcher, context);
-    }
-    return true;
-}
-
-/**
- * @brief Initialize a Submenu object
- * @note This does not set the items in the submenu
- * @param submenu The Submenu object to initialize
- * @param view_id The ID/Index of the view
- * @param title The title/header of the submenu
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_submenu(
-    Submenu **submenu,
-    int32_t view_id,
-    char *title,
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher)
-{
-    if (!submenu)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_submenu");
-        return false;
-    }
-    *submenu = submenu_alloc();
-    if (!*submenu)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate Submenu");
-        return false;
-    }
-    if (title)
-    {
-        submenu_set_header(*submenu, title);
-    }
-    if (previous_callback)
-    {
-        view_set_previous_callback(submenu_get_view(*submenu), previous_callback);
-    }
-    view_dispatcher_add_view(*view_dispatcher, view_id, submenu_get_view(*submenu));
-    return true;
-}
-/**
- * @brief Initialize a Menu object
- * @note This does not set the items in the menu
- * @param menu The Menu object to initialize
- * @param view_id The ID/Index of the view
- * @param item_callback The item callback function
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_menu(
-    Menu **menu,
-    int32_t view_id,
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher)
-{
-    if (!menu)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_menu");
-        return false;
-    }
-    *menu = menu_alloc();
-    if (!*menu)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate Menu");
-        return false;
-    }
-    if (previous_callback)
-    {
-        view_set_previous_callback(menu_get_view(*menu), previous_callback);
-    }
-    view_dispatcher_add_view(*view_dispatcher, view_id, menu_get_view(*menu));
-    return true;
-}
-
-/**
- * @brief Initialize a Widget object
- * @param widget The Widget object to initialize
- * @param view_id The ID/Index of the view
- * @param text The text to display in the widget
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_widget(
-    Widget **widget,
-    int32_t view_id,
-    char *text,
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher)
-{
-    if (!widget)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_widget");
-        return false;
-    }
-    *widget = widget_alloc();
-    if (!*widget)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate Widget");
-        return false;
-    }
-    if (text)
-    {
-        widget_add_text_scroll_element(*widget, 0, 0, 128, 64, text);
-    }
-    if (previous_callback)
-    {
-        view_set_previous_callback(widget_get_view(*widget), previous_callback);
-    }
-    view_dispatcher_add_view(*view_dispatcher, view_id, widget_get_view(*widget));
-    return true;
-}
-
-/**
- * @brief Initialize a VariableItemList object
- * @note This does not set the items in the VariableItemList
- * @param variable_item_list The VariableItemList object to initialize
- * @param view_id The ID/Index of the view
- * @param enter_callback The enter callback function (can be set to NULL)
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @param context The context to pass to the enter callback (usually the app)
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_variable_item_list(
-    VariableItemList **variable_item_list,
-    int32_t view_id,
-    void (*enter_callback)(void *, uint32_t),
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context)
-{
-    if (!variable_item_list)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_variable_item_list");
-        return false;
-    }
-    *variable_item_list = variable_item_list_alloc();
-    if (!*variable_item_list)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate VariableItemList");
-        return false;
-    }
-    if (enter_callback)
-    {
-        variable_item_list_set_enter_callback(*variable_item_list, enter_callback, context);
-    }
-    if (previous_callback)
-    {
-        view_set_previous_callback(variable_item_list_get_view(*variable_item_list), previous_callback);
-    }
-    view_dispatcher_add_view(*view_dispatcher, view_id, variable_item_list_get_view(*variable_item_list));
-    return true;
-}
-
-/**
- * @brief Initialize a TextInput object
- * @param text_input The TextInput object to initialize
- * @param view_id The ID/Index of the view
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_text_input(
-    TextInput **text_input,
-    int32_t view_id,
-    char *header_text,
-    char *text_input_temp_buffer,
-    uint32_t text_input_buffer_size,
-    void (*result_callback)(void *),
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context)
-{
-    if (!text_input)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_text_input");
-        return false;
-    }
-    *text_input = text_input_alloc();
-    if (!*text_input)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate TextInput");
-        return false;
-    }
-    if (previous_callback)
-    {
-        view_set_previous_callback(text_input_get_view(*text_input), previous_callback);
-    }
-    if (header_text)
-    {
-        text_input_set_header_text(*text_input, header_text);
-    }
-    if (text_input_temp_buffer && text_input_buffer_size && result_callback)
-    {
-        text_input_set_result_callback(*text_input, result_callback, context, text_input_temp_buffer, text_input_buffer_size, false);
-    }
-    view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*text_input));
-    return true;
-}
-
-/**
- * @brief Initialize a UART_TextInput object
- * @param uart_text_input The UART_TextInput object to initialize
- * @param view_id The ID/Index of the view
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_uart_text_input(
-    UART_TextInput **uart_text_input,
-    int32_t view_id,
-    char *header_text,
-    char *uart_text_input_temp_buffer,
-    uint32_t uart_text_input_buffer_size,
-    void (*result_callback)(void *),
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context)
-{
-    if (!uart_text_input)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_uart_text_input");
-        return false;
-    }
-    *uart_text_input = uart_text_input_alloc();
-    if (!*uart_text_input)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate UART_TextInput");
-        return false;
-    }
-    if (previous_callback)
-    {
-        view_set_previous_callback(uart_text_input_get_view(*uart_text_input), previous_callback);
-    }
-    if (header_text)
-    {
-        uart_text_input_set_header_text(*uart_text_input, header_text);
-    }
-    if (uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback)
-    {
-        uart_text_input_set_result_callback(*uart_text_input, result_callback, context, uart_text_input_temp_buffer, uart_text_input_buffer_size, false);
-    }
-    view_dispatcher_add_view(*view_dispatcher, view_id, uart_text_input_get_view(*uart_text_input));
-    return true;
-}
-
-/**
- * @brief Initialize a DialogEx object
- * @param dialog_ex The DialogEx object to initialize
- * @param view_id The ID/Index of the view
- * @param header The header of the dialog
- * @param header_x The x coordinate of the header
- * @param header_y The y coordinate of the header
- * @param text The text of the dialog
- * @param text_x The x coordinate of the dialog
- * @param text_y The y coordinate of the dialog
- * @param left_button_text The text of the left button
- * @param right_button_text The text of the right button
- * @param center_button_text The text of the center button
- * @param result_callback The result callback function
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @param context The context to pass to the result callback
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_dialog_ex(
-    DialogEx **dialog_ex,
-    int32_t view_id,
-    char *header,
-    uint16_t header_x,
-    uint16_t header_y,
-    char *text,
-    uint16_t text_x,
-    uint16_t text_y,
-    char *left_button_text,
-    char *right_button_text,
-    char *center_button_text,
-    void (*result_callback)(DialogExResult, void *),
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context)
-{
-    if (!dialog_ex)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_dialog_ex");
-        return false;
-    }
-    *dialog_ex = dialog_ex_alloc();
-    if (!*dialog_ex)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate DialogEx");
-        return false;
-    }
-    if (header)
-    {
-        dialog_ex_set_header(*dialog_ex, header, header_x, header_y, AlignLeft, AlignTop);
-    }
-    if (text)
-    {
-        dialog_ex_set_text(*dialog_ex, text, text_x, text_y, AlignLeft, AlignTop);
-    }
-    if (left_button_text)
-    {
-        dialog_ex_set_left_button_text(*dialog_ex, left_button_text);
-    }
-    if (right_button_text)
-    {
-        dialog_ex_set_right_button_text(*dialog_ex, right_button_text);
-    }
-    if (center_button_text)
-    {
-        dialog_ex_set_center_button_text(*dialog_ex, center_button_text);
-    }
-    if (result_callback)
-    {
-        dialog_ex_set_result_callback(*dialog_ex, result_callback);
-    }
-    if (previous_callback)
-    {
-        view_set_previous_callback(dialog_ex_get_view(*dialog_ex), previous_callback);
-    }
-    if (context)
-    {
-        dialog_ex_set_context(*dialog_ex, context);
-    }
-    view_dispatcher_add_view(*view_dispatcher, view_id, dialog_ex_get_view(*dialog_ex));
-    return true;
-}
-
-/**
- * @brief Initialize a Popup object
- * @param popup The Popup object to initialize
- * @param view_id The ID/Index of the view
- * @param header The header of the dialog
- * @param header_x The x coordinate of the header
- * @param header_y The y coordinate of the header
- * @param text The text of the dialog
- * @param text_x The x coordinate of the dialog
- * @param text_y The y coordinate of the dialog
- * @param result_callback The result callback function
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @param context The context to pass to the result callback
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_popup(
-    Popup **popup,
-    int32_t view_id,
-    char *header,
-    uint16_t header_x,
-    uint16_t header_y,
-    char *text,
-    uint16_t text_x,
-    uint16_t text_y,
-    void (*result_callback)(void *),
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context)
-{
-    if (!popup)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_popup");
-        return false;
-    }
-    *popup = popup_alloc();
-    if (!*popup)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate Popup");
-        return false;
-    }
-    if (header)
-    {
-        popup_set_header(*popup, header, header_x, header_y, AlignLeft, AlignTop);
-    }
-    if (text)
-    {
-        popup_set_text(*popup, text, text_x, text_y, AlignLeft, AlignTop);
-    }
-    if (result_callback)
-    {
-        popup_set_callback(*popup, result_callback);
-    }
-    if (previous_callback)
-    {
-        view_set_previous_callback(popup_get_view(*popup), previous_callback);
-    }
-    if (context)
-    {
-        popup_set_context(*popup, context);
-    }
-    view_dispatcher_add_view(*view_dispatcher, view_id, popup_get_view(*popup));
-    return true;
-}
-
-/**
- * @brief Initialize a Loading object
- * @param loading The Loading object to initialize
- * @param view_id The ID/Index of the view
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_loading(
-    Loading **loading,
-    int32_t view_id,
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher)
-{
-    if (!loading)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_loading");
-        return false;
-    }
-    *loading = loading_alloc();
-    if (!*loading)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate Loading");
-        return false;
-    }
-    if (previous_callback)
-    {
-        view_set_previous_callback(loading_get_view(*loading), previous_callback);
-    }
-    view_dispatcher_add_view(*view_dispatcher, view_id, loading_get_view(*loading));
-    return true;
-}
-
-/**
- * @brief Set a char butter to a FuriString
- * @param furi_string The FuriString object
- * @param buffer The buffer to copy the string to
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer)
-{
-    if (!furi_string)
-    {
-        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_buffer_to_furi_string");
-        return false;
-    }
-    *furi_string = furi_string_alloc();
-    if (!furi_string)
-    {
-        FURI_LOG_E(EASY_TAG, "Failed to allocate FuriString");
-        return false;
-    }
-    furi_string_set_str(*furi_string, buffer);
-    return true;
-}

+ 0 - 269
easy_flipper/easy_flipper.h

@@ -1,269 +0,0 @@
-#ifndef EASY_FLIPPER_H
-#define EASY_FLIPPER_H
-
-#include <malloc.h>
-#include <furi.h>
-#include <furi_hal.h>
-#include <gui/gui.h>
-#include <gui/view.h>
-#include <gui/modules/submenu.h>
-#include <gui/view_dispatcher.h>
-#include <gui/elements.h>
-#include <gui/modules/menu.h>
-#include <gui/modules/submenu.h>
-#include <gui/modules/widget.h>
-#include <gui/modules/text_input.h>
-#include <gui/modules/text_box.h>
-#include <gui/modules/variable_item_list.h>
-#include <gui/modules/dialog_ex.h>
-#include <notification/notification.h>
-#include <dialogs/dialogs.h>
-#include <gui/modules/popup.h>
-#include <gui/modules/loading.h>
-#include <text_input/uart_text_input.h>
-#include <stdio.h>
-#include <string.h>
-#include <jsmn/jsmn.h>
-
-#define EASY_TAG "EasyFlipper"
-
-void easy_flipper_dialog(
-    char *header,
-    char *text);
-
-/**
- * @brief Navigation callback for exiting the application
- * @param context The context - unused
- * @return next view id (VIEW_NONE to exit the app)
- */
-uint32_t easy_flipper_callback_exit_app(void *context);
-/**
- * @brief Initialize a buffer
- * @param buffer The buffer to initialize
- * @param buffer_size The size of the buffer
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_buffer(char **buffer, uint32_t buffer_size);
-/**
- * @brief Initialize a View object
- * @param view The View object to initialize
- * @param view_id The ID/Index of the view
- * @param draw_callback The draw callback function (set to NULL if not needed)
- * @param input_callback The input callback function (set to NULL if not needed)
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_view(
-    View **view,
-    int32_t view_id,
-    void draw_callback(Canvas *, void *),
-    bool input_callback(InputEvent *, void *),
-    uint32_t (*previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context);
-
-/**
- * @brief Initialize a ViewDispatcher object
- * @param view_dispatcher The ViewDispatcher object to initialize
- * @param gui The GUI object
- * @param context The context to pass to the event callback
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_view_dispatcher(ViewDispatcher **view_dispatcher, Gui *gui, void *context);
-
-/**
- * @brief Initialize a Submenu object
- * @note This does not set the items in the submenu
- * @param submenu The Submenu object to initialize
- * @param view_id The ID/Index of the view
- * @param title The title/header of the submenu
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_submenu(
-    Submenu **submenu,
-    int32_t view_id,
-    char *title,
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher);
-
-/**
- * @brief Initialize a Menu object
- * @note This does not set the items in the menu
- * @param menu The Menu object to initialize
- * @param view_id The ID/Index of the view
- * @param item_callback The item callback function
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_menu(
-    Menu **menu,
-    int32_t view_id,
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher);
-
-/**
- * @brief Initialize a Widget object
- * @param widget The Widget object to initialize
- * @param view_id The ID/Index of the view
- * @param text The text to display in the widget
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_widget(
-    Widget **widget,
-    int32_t view_id,
-    char *text,
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher);
-
-/**
- * @brief Initialize a VariableItemList object
- * @note This does not set the items in the VariableItemList
- * @param variable_item_list The VariableItemList object to initialize
- * @param view_id The ID/Index of the view
- * @param enter_callback The enter callback function (can be set to NULL)
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @param context The context to pass to the enter callback (usually the app)
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_variable_item_list(
-    VariableItemList **variable_item_list,
-    int32_t view_id,
-    void (*enter_callback)(void *, uint32_t),
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context);
-
-/**
- * @brief Initialize a TextInput object
- * @param text_input The TextInput object to initialize
- * @param view_id The ID/Index of the view
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_text_input(
-    TextInput **text_input,
-    int32_t view_id,
-    char *header_text,
-    char *text_input_temp_buffer,
-    uint32_t text_input_buffer_size,
-    void (*result_callback)(void *),
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context);
-
-/**
- * @brief Initialize a UART_TextInput object
- * @param uart_text_input The UART_TextInput object to initialize
- * @param view_id The ID/Index of the view
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_uart_text_input(
-    UART_TextInput **uart_text_input,
-    int32_t view_id,
-    char *header_text,
-    char *uart_text_input_temp_buffer,
-    uint32_t uart_text_input_buffer_size,
-    void (*result_callback)(void *),
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context);
-
-/**
- * @brief Initialize a DialogEx object
- * @param dialog_ex The DialogEx object to initialize
- * @param view_id The ID/Index of the view
- * @param header The header of the dialog
- * @param header_x The x coordinate of the header
- * @param header_y The y coordinate of the header
- * @param text The text of the dialog
- * @param text_x The x coordinate of the dialog
- * @param text_y The y coordinate of the dialog
- * @param left_button_text The text of the left button
- * @param right_button_text The text of the right button
- * @param center_button_text The text of the center button
- * @param result_callback The result callback function
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @param context The context to pass to the result callback
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_dialog_ex(
-    DialogEx **dialog_ex,
-    int32_t view_id,
-    char *header,
-    uint16_t header_x,
-    uint16_t header_y,
-    char *text,
-    uint16_t text_x,
-    uint16_t text_y,
-    char *left_button_text,
-    char *right_button_text,
-    char *center_button_text,
-    void (*result_callback)(DialogExResult, void *),
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context);
-
-/**
- * @brief Initialize a Popup object
- * @param popup The Popup object to initialize
- * @param view_id The ID/Index of the view
- * @param header The header of the dialog
- * @param header_x The x coordinate of the header
- * @param header_y The y coordinate of the header
- * @param text The text of the dialog
- * @param text_x The x coordinate of the dialog
- * @param text_y The y coordinate of the dialog
- * @param result_callback The result callback function
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @param context The context to pass to the result callback
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_popup(
-    Popup **popup,
-    int32_t view_id,
-    char *header,
-    uint16_t header_x,
-    uint16_t header_y,
-    char *text,
-    uint16_t text_x,
-    uint16_t text_y,
-    void (*result_callback)(void *),
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher,
-    void *context);
-
-/**
- * @brief Initialize a Loading object
- * @param loading The Loading object to initialize
- * @param view_id The ID/Index of the view
- * @param previous_callback The previous callback function (can be set to NULL)
- * @param view_dispatcher The ViewDispatcher object
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_loading(
-    Loading **loading,
-    int32_t view_id,
-    uint32_t(previous_callback)(void *),
-    ViewDispatcher **view_dispatcher);
-
-/**
- * @brief Set a char butter to a FuriString
- * @param furi_string The FuriString object
- * @param buffer The buffer to copy the string to
- * @return true if successful, false otherwise
- */
-bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer);
-
-#endif

+ 0 - 106
firmwares/flip_store_firmwares.c

@@ -1,106 +0,0 @@
-#include <firmwares/flip_store_firmwares.h>
-
-Firmware *firmwares = NULL;
-VGMFirmware *vgm_firmwares = NULL;
-bool is_esp32_firmware = true;
-
-Firmware *firmware_alloc()
-{
-    Firmware *fw = (Firmware *)malloc(FIRMWARE_COUNT * sizeof(Firmware));
-    if (!fw)
-    {
-        FURI_LOG_E(TAG, "Failed to allocate memory for Firmware");
-        return NULL;
-    }
-
-    // Black Magic
-    snprintf(fw[0].name, sizeof(fw[0].name), "%s", "Black Magic");
-    snprintf(fw[0].links[0], sizeof(fw[0].links[0]), "%s", "https://raw.githubusercontent.com/FZEEFlasher/fzeeflasher.github.io/main/resources/STATIC/BM/bootloader.bin");
-    snprintf(fw[0].links[1], sizeof(fw[0].links[1]), "%s", "https://raw.githubusercontent.com/FZEEFlasher/fzeeflasher.github.io/main/resources/STATIC/BM/partition-table.bin");
-    snprintf(fw[0].links[2], sizeof(fw[0].links[2]), "%s", "https://raw.githubusercontent.com/FZEEFlasher/fzeeflasher.github.io/main/resources/STATIC/BM/blackmagic.bin");
-
-    // FlipperHTTP
-    snprintf(fw[1].name, sizeof(fw[1].name), "%s", "FlipperHTTP");
-    snprintf(fw[1].links[0], sizeof(fw[1].links[0]), "%s", "https://raw.githubusercontent.com/jblanked/FlipperHTTP/main/WiFi%20Developer%20Board%20(ESP32S2)/flipper_http_bootloader.bin");
-    snprintf(fw[1].links[1], sizeof(fw[1].links[1]), "%s", "https://raw.githubusercontent.com/jblanked/FlipperHTTP/main/WiFi%20Developer%20Board%20(ESP32S2)/flipper_http_firmware_a.bin");
-    snprintf(fw[1].links[2], sizeof(fw[1].links[2]), "%s", "https://raw.githubusercontent.com/jblanked/FlipperHTTP/main/WiFi%20Developer%20Board%20(ESP32S2)/flipper_http_partitions.bin");
-
-    // Marauder
-    snprintf(fw[2].name, sizeof(fw[2].name), "%s", "Marauder");
-    snprintf(fw[2].links[0], sizeof(fw[2].links[0]), "%s", "https://raw.githubusercontent.com/FZEEFlasher/fzeeflasher.github.io/main/resources/STATIC/M/FLIPDEV/esp32_marauder.ino.bootloader.bin");
-    snprintf(fw[2].links[1], sizeof(fw[2].links[1]), "%s", "https://raw.githubusercontent.com/FZEEFlasher/fzeeflasher.github.io/main/resources/STATIC/M/FLIPDEV/esp32_marauder.ino.partitions.bin");
-    snprintf(fw[2].links[2], sizeof(fw[2].links[2]), "%s", "https://raw.githubusercontent.com/FZEEFlasher/fzeeflasher.github.io/main/resources/CURRENT/esp32_marauder_v1_2_0_12192024_flipper.bin");
-
-    return fw;
-}
-
-VGMFirmware *vgm_firmware_alloc()
-{
-    VGMFirmware *fw = (VGMFirmware *)malloc(VGM_FIRMWARE_COUNT * sizeof(VGMFirmware));
-    if (!fw)
-    {
-        FURI_LOG_E(TAG, "Failed to allocate memory for VGM Firmware");
-        return NULL;
-    }
-
-    // FlipperHTTP
-    snprintf(fw[0].name, sizeof(fw[0].name), "%s", "FlipperHTTP");
-    snprintf(fw[0].link, sizeof(fw[0].link), "%s", "https://raw.githubusercontent.com/jblanked/FlipperHTTP/main/Video%20Game%20Module/MicroPython/flipper_http_vgm_micro_python.uf2");
-
-    return fw;
-}
-
-void firmware_free()
-{
-    if (firmwares)
-    {
-        free(firmwares);
-        firmwares = NULL;
-    }
-}
-void vgm_firmware_free()
-{
-    if (vgm_firmwares)
-    {
-        free(vgm_firmwares);
-        vgm_firmwares = NULL;
-    }
-}
-
-bool flip_store_get_firmware_file(FlipperHTTP *fhttp, char *link, char *name, char *filename)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(TAG, "FlipperHTTP is NULL");
-        return false;
-    }
-    if (fhttp->state == INACTIVE)
-    {
-        return false;
-    }
-
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-
-    char directory_path[64];
-    // save in ESP32 flasher directory
-    if (is_esp32_firmware)
-    {
-        snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/esp_flasher");
-        storage_common_mkdir(storage, directory_path);
-        snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/esp_flasher/%s", firmwares[selected_firmware_index].name);
-        storage_common_mkdir(storage, directory_path);
-        snprintf(fhttp->file_path, sizeof(fhttp->file_path), STORAGE_EXT_PATH_PREFIX "/apps_data/esp_flasher/%s/%s", name, filename);
-    }
-    else // install in app_data directory
-    {
-        snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/vgm");
-        storage_common_mkdir(storage, directory_path);
-        snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/vgm/%s", name);
-        storage_common_mkdir(storage, directory_path);
-        snprintf(fhttp->file_path, sizeof(fhttp->file_path), STORAGE_EXT_PATH_PREFIX "/apps_data/vgm/%s/%s", name, filename);
-    }
-    furi_record_close(RECORD_STORAGE);
-    fhttp->save_received_data = false;
-    fhttp->is_bytes_request = true;
-    return flipper_http_get_request_bytes(fhttp, link, "{\"Content-Type\":\"application/octet-stream\"}");
-}

+ 0 - 31
firmwares/flip_store_firmwares.h

@@ -1,31 +0,0 @@
-#ifndef FLIP_STORE_FIRMWARES_H
-#define FLIP_STORE_FIRMWARES_H
-
-#include <flip_store.h>
-#include <flip_storage/flip_store_storage.h>
-#include <callback/flip_store_callback.h>
-
-typedef struct
-{
-    char name[16];
-    char links[FIRMWARE_LINKS][256];
-} Firmware;
-
-typedef struct
-{
-    char name[16];
-    char link[256];
-} VGMFirmware;
-
-extern Firmware *firmwares;
-extern VGMFirmware *vgm_firmwares;
-Firmware *firmware_alloc();
-VGMFirmware *vgm_firmware_alloc();
-void firmware_free();
-void vgm_firmware_free();
-extern bool is_esp32_firmware;
-
-// download and waiting process
-bool flip_store_get_firmware_file(FlipperHTTP *fhttp, char *link, char *name, char *filename);
-
-#endif // FLIP_STORE_FIRMWARES_H

+ 0 - 446
flip_storage/flip_store_storage.c

@@ -1,446 +0,0 @@
-#include "flip_storage/flip_store_storage.h"
-
-void save_settings(
-    const char *ssid,
-    const char *password)
-{
-    // Create the directory for saving settings
-    char directory_path[128];
-    snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store");
-
-    // Create the directory
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    storage_common_mkdir(storage, directory_path);
-
-    // Open the settings file
-    File *file = storage_file_alloc(storage);
-    if (!storage_file_open(file, SETTINGS_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS))
-    {
-        FURI_LOG_E(TAG, "Failed to open settings file for writing: %s", SETTINGS_PATH);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return;
-    }
-
-    // Save the ssid length and data
-    size_t ssid_length = strlen(ssid) + 1; // Include null terminator
-    if (storage_file_write(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) ||
-        storage_file_write(file, ssid, ssid_length) != ssid_length)
-    {
-        FURI_LOG_E(TAG, "Failed to write SSID");
-    }
-
-    // Save the password length and data
-    size_t password_length = strlen(password) + 1; // Include null terminator
-    if (storage_file_write(file, &password_length, sizeof(size_t)) != sizeof(size_t) ||
-        storage_file_write(file, password, password_length) != password_length)
-    {
-        FURI_LOG_E(TAG, "Failed to write password");
-    }
-
-    storage_file_close(file);
-    storage_file_free(file);
-    furi_record_close(RECORD_STORAGE);
-}
-
-bool load_settings(
-    char *ssid,
-    size_t ssid_size,
-    char *password,
-    size_t password_size)
-{
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    File *file = storage_file_alloc(storage);
-
-    if (!storage_file_open(file, SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING))
-    {
-        FURI_LOG_E(TAG, "Failed to open settings file for reading: %s", SETTINGS_PATH);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false; // Return false if the file does not exist
-    }
-
-    // Load the ssid
-    size_t ssid_length;
-    if (storage_file_read(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) || ssid_length > ssid_size ||
-        storage_file_read(file, ssid, ssid_length) != ssid_length)
-    {
-        FURI_LOG_E(TAG, "Failed to read SSID");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
-    ssid[ssid_length - 1] = '\0'; // Ensure null-termination
-
-    // Load the password
-    size_t password_length;
-    if (storage_file_read(file, &password_length, sizeof(size_t)) != sizeof(size_t) || password_length > password_size ||
-        storage_file_read(file, password, password_length) != password_length)
-    {
-        FURI_LOG_E(TAG, "Failed to read password");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
-    password[password_length - 1] = '\0'; // Ensure null-termination
-
-    storage_file_close(file);
-    storage_file_free(file);
-    furi_record_close(RECORD_STORAGE);
-
-    return true;
-}
-
-// future implenetation because we need the app category
-bool delete_app(const char *app_id, const char *app_category)
-{
-    // Create the directory for saving settings
-    char directory_path[128];
-    snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps/%s/%s", app_category, app_id);
-
-    // Create the directory
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    if (!storage_simply_remove_recursive(storage, directory_path))
-    {
-        FURI_LOG_E(TAG, "Failed to delete app: %s", app_id);
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
-
-    furi_record_close(RECORD_STORAGE);
-    return true;
-}
-
-bool app_exists(const char *app_id, const char *app_category)
-{
-    // Check if the app exists
-    char directory_path[128];
-    snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps/%s/%s.fap", app_category, app_id);
-
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    bool exists = storage_common_exists(storage, directory_path);
-    furi_record_close(RECORD_STORAGE);
-
-    return exists;
-}
-
-// Function to parse JSON incrementally from a file
-bool parse_json_incrementally(const char *file_path, const char *target_key, char *value_buffer, size_t value_buffer_size)
-{
-    Storage *_storage = NULL;
-    File *_file = NULL;
-    char buffer[BUFFER_SIZE];
-    size_t bytes_read;
-    bool key_found = false;
-    bool in_string = false;
-    bool is_escaped = false;
-    bool reading_key = false;
-    bool reading_value = false;
-    char current_key[MAX_KEY_LENGTH] = {0};
-    size_t key_index = 0;
-    size_t value_index = 0;
-
-    // Open storage and file
-    _storage = furi_record_open(RECORD_STORAGE);
-    if (!_storage)
-    {
-        FURI_LOG_E("JSON_PARSE", "Failed to open storage.");
-        return false;
-    }
-
-    _file = storage_file_alloc(_storage);
-    if (!_file)
-    {
-        FURI_LOG_E("JSON_PARSE", "Failed to allocate file.");
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
-
-    if (!storage_file_open(_file, file_path, FSAM_READ, FSOM_OPEN_EXISTING))
-    {
-        FURI_LOG_E("JSON_PARSE", "Failed to open JSON file for reading.");
-        goto cleanup;
-    }
-
-    while ((bytes_read = storage_file_read(_file, buffer, BUFFER_SIZE)) > 0)
-    {
-        for (size_t i = 0; i < bytes_read; ++i)
-        {
-            char c = buffer[i];
-
-            if (is_escaped)
-            {
-                is_escaped = false;
-                if (reading_key)
-                {
-                    if (key_index < MAX_KEY_LENGTH - 1)
-                    {
-                        current_key[key_index++] = c;
-                    }
-                }
-                else if (reading_value)
-                {
-                    if (value_index < value_buffer_size - 1)
-                    {
-                        value_buffer[value_index++] = c;
-                    }
-                }
-                continue;
-            }
-
-            if (c == '\\')
-            {
-                is_escaped = true;
-                continue;
-            }
-
-            if (c == '\"')
-            {
-                in_string = !in_string;
-
-                if (in_string)
-                {
-                    // Start of a string
-                    if (!reading_key && !reading_value)
-                    {
-                        // Possible start of a key
-                        reading_key = true;
-                        key_index = 0;
-                        current_key[0] = '\0';
-                    }
-                }
-                else
-                {
-                    // End of a string
-                    if (reading_key)
-                    {
-                        reading_key = false;
-                        current_key[key_index] = '\0';
-
-                        if (strcmp(current_key, target_key) == 0)
-                        {
-                            key_found = true;
-                        }
-                    }
-                    else if (reading_value)
-                    {
-                        reading_value = false;
-                        value_buffer[value_index] = '\0';
-
-                        if (key_found)
-                        {
-                            // Found the target value
-                            goto success;
-                        }
-                    }
-                }
-                continue;
-            }
-
-            if (in_string)
-            {
-                if (reading_key)
-                {
-                    if (key_index < MAX_KEY_LENGTH - 1)
-                    {
-                        current_key[key_index++] = c;
-                    }
-                }
-                else if (reading_value)
-                {
-                    if (value_index < value_buffer_size - 1)
-                    {
-                        value_buffer[value_index++] = c;
-                    }
-                }
-                continue;
-            }
-
-            if (c == ':' && key_found && !reading_value)
-            {
-                // After colon, start reading the value
-                // Skip whitespace and possible opening quote
-                while (i + 1 < bytes_read && (buffer[i + 1] == ' ' || buffer[i + 1] == '\n' || buffer[i + 1] == '\r'))
-                {
-                    i++;
-                }
-
-                if (i + 1 < bytes_read && buffer[i + 1] == '\"')
-                {
-                    i++; // Move to the quote
-                    in_string = true;
-                    reading_value = true;
-                    value_index = 0;
-                }
-                else
-                {
-                    // Handle non-string values (e.g., numbers, booleans)
-                    reading_value = true;
-                    value_index = 0;
-                }
-                continue;
-            }
-
-            if (reading_value && (c == ',' || c == '}' || c == ']'))
-            {
-                // End of the value
-                reading_value = false;
-                value_buffer[value_index] = '\0';
-
-                if (key_found)
-                {
-                    // Found the target value
-                    goto success;
-                }
-                key_found = false;
-            }
-        }
-    }
-
-success:
-    storage_file_close(_file);
-    storage_file_free(_file);
-    furi_record_close(RECORD_STORAGE);
-    return key_found;
-
-cleanup:
-    if (_file)
-    {
-        storage_file_free(_file);
-    }
-    if (_storage)
-    {
-        furi_record_close(RECORD_STORAGE);
-    }
-    return false;
-}
-
-bool save_char(
-    const char *path_name, const char *value)
-{
-    if (!value)
-    {
-        return false;
-    }
-    // Create the directory for saving settings
-    char directory_path[256];
-    snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data");
-
-    // Create the directory
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    storage_common_mkdir(storage, directory_path);
-
-    // Open the settings file
-    File *file = storage_file_alloc(storage);
-    char file_path[256];
-    snprintf(file_path, sizeof(file_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data/%s.txt", path_name);
-
-    // Open the file in write mode
-    if (!storage_file_open(file, file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS))
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to open file for writing: %s", file_path);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
-
-    // Write the data to the file
-    size_t data_size = strlen(value) + 1; // Include null terminator
-    if (storage_file_write(file, value, data_size) != data_size)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to append data to file");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
-
-    storage_file_close(file);
-    storage_file_free(file);
-    furi_record_close(RECORD_STORAGE);
-
-    return true;
-}
-
-bool load_char(
-    const char *path_name,
-    char *value,
-    size_t value_size)
-{
-    if (!value)
-    {
-        return false;
-    }
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    File *file = storage_file_alloc(storage);
-
-    char file_path[256];
-    snprintf(file_path, sizeof(file_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data/%s.txt", path_name);
-
-    // Open the file for reading
-    if (!storage_file_open(file, file_path, FSAM_READ, FSOM_OPEN_EXISTING))
-    {
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return NULL; // Return false if the file does not exist
-    }
-
-    // Read data into the buffer
-    size_t read_count = storage_file_read(file, value, value_size);
-    if (storage_file_get_error(file) != FSE_OK)
-    {
-        FURI_LOG_E(HTTP_TAG, "Error reading from file.");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
-
-    // Ensure null-termination
-    value[read_count - 1] = '\0';
-
-    storage_file_close(file);
-    storage_file_free(file);
-    furi_record_close(RECORD_STORAGE);
-
-    return true;
-}
-
-bool save_char_with_path(const char *full_path, const char *value)
-{
-    if (!value)
-    {
-        return false;
-    }
-
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    File *file = storage_file_alloc(storage);
-
-    // Open the file in write mode
-    if (!storage_file_open(file, full_path, FSAM_WRITE, FSOM_CREATE_ALWAYS))
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to open file for writing: %s", full_path);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
-
-    // Write the data to the file
-    size_t data_size = strlen(value) + 1; // Include null terminator
-    if (storage_file_write(file, value, data_size) != data_size)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to append data to file");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
-
-    storage_file_close(file);
-    storage_file_free(file);
-    furi_record_close(RECORD_STORAGE);
-
-    return true;
-}

+ 0 - 40
flip_storage/flip_store_storage.h

@@ -1,40 +0,0 @@
-#ifndef FLIP_STORE_STORAGE_H
-#define FLIP_STORE_STORAGE_H
-
-#include <furi.h>
-#include <storage/storage.h>
-#include <flip_store.h>
-
-#define SETTINGS_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/settings.bin"
-#define BUFFER_SIZE 64
-#define MAX_KEY_LENGTH 16
-#define MAX_VALUE_LENGTH 100
-
-void save_settings(
-    const char *ssid,
-    const char *password);
-
-bool load_settings(
-    char *ssid,
-    size_t ssid_size,
-    char *password,
-    size_t password_size);
-
-bool delete_app(const char *app_id, const char *app_category);
-
-bool app_exists(const char *app_id, const char *app_category);
-
-// Function to parse JSON incrementally from a file
-bool parse_json_incrementally(const char *file_path, const char *target_key, char *value_buffer, size_t value_buffer_size);
-
-bool save_char(
-    const char *path_name, const char *value);
-
-bool load_char(
-    const char *path_name,
-    char *value,
-    size_t value_size);
-
-bool save_char_with_path(const char *full_path, const char *value);
-
-#endif

+ 0 - 67
flip_store.c

@@ -1,67 +0,0 @@
-#include <flip_store.h>
-#include <apps/flip_store_apps.h>
-
-// Function to free the resources used by FlipStoreApp
-void flip_store_app_free(FlipStoreApp *app)
-{
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipStoreApp is NULL");
-        return;
-    }
-
-    // Free Widget(s)
-    if (app->widget_result)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewWidgetResult);
-        widget_free(app->widget_result);
-    }
-
-    // Free View(s)
-    if (app->view_loader)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewLoader);
-        flip_store_loader_free_model(app->view_loader);
-        view_free(app->view_loader);
-    }
-
-    // Free Submenu(s)
-    if (app->submenu_main)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewSubmenu);
-        submenu_free(app->submenu_main);
-    }
-    if (app->submenu_options)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewSubmenuOptions);
-        submenu_free(app->submenu_options);
-    }
-    if (app->submenu_app_list)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewAppList);
-        submenu_free(app->submenu_app_list);
-    }
-    if (app->submenu_firmwares)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewFirmwares);
-        submenu_free(app->submenu_firmwares);
-    }
-    if (app->submenu_vgm_firmwares)
-    {
-        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewVGMFirmwares);
-        submenu_free(app->submenu_vgm_firmwares);
-    }
-
-    free_all_views(app, true);
-
-    // free the view dispatcher
-    if (app->view_dispatcher)
-        view_dispatcher_free(app->view_dispatcher);
-
-    // close the gui
-    furi_record_close(RECORD_GUI);
-
-    // free the app
-    if (app)
-        free(app);
-}

+ 0 - 121
flip_store.h

@@ -1,121 +0,0 @@
-#ifndef FLIP_STORE_E_H
-#define FLIP_STORE_E_H
-#include <text_input/uart_text_input.h>
-#include <flipper_http/flipper_http.h>
-#include <easy_flipper/easy_flipper.h>
-#include <furi.h>
-#include <furi_hal.h>
-#include <gui/gui.h>
-#include <gui/view.h>
-#include <gui/modules/submenu.h>
-#include <gui/view_dispatcher.h>
-#include <notification/notification.h>
-#include <dialogs/dialogs.h>
-#include <jsmn/jsmn.h>
-#include <jsmn/jsmn_furi.h>
-#include <flip_store_icons.h>
-
-#define TAG "FlipStore"
-#define VERSION_TAG "FlipStore v0.8"
-
-#define FIRMWARE_COUNT 3
-#define FIRMWARE_LINKS 3
-
-#define VGM_FIRMWARE_COUNT 1
-#define VGM_FIRMWARE_LINKS 1
-
-#define MAX_GITHUB_FILES 30
-
-// Define the submenu items for our FlipStore application
-typedef enum
-{
-    FlipStoreSubmenuIndexMain, // Click to start downloading the selected app
-    FlipStoreSubmenuIndexAbout,
-    FlipStoreSubmenuIndexSettings,
-    //
-    FlipStoreSubmenuIndexOptions, // Click to view the options
-    //
-    FlipStoreSubmenuIndexAppList,      // Click to view the app list
-    FlipStoreSubmenuIndexFirmwares,    // Click to view the ESP32 firmwares
-    FlipStoreSubmenuIndexVGMFirmwares, // Click to view the VGM firmwares
-    FlipStoreSubmenuIndexGitHub,       // Click to view the GitHub repository view
-    //
-    FlipStoreSubmenuIndexAppListBluetooth,
-    FlipStoreSubmenuIndexAppListGames,
-    FlipStoreSubmenuIndexAppListGPIO,
-    FlipStoreSubmenuIndexAppListInfrared,
-    FlipStoreSubmenuIndexAppListiButton,
-    FlipStoreSubmenuIndexAppListMedia,
-    FlipStoreSubmenuIndexAppListNFC,
-    FlipStoreSubmenuIndexAppListRFID,
-    FlipStoreSubmenuIndexAppListSubGHz,
-    FlipStoreSubmenuIndexAppListTools,
-    FlipStoreSubmenuIndexAppListUSB,
-    //
-    FlipStoreSubmenuIndexStartFirmwares = 50,
-    FlipStoreSubmenuIndexStartVGMFirmwares = 60,
-    //
-    FlipStoreSubmenuIndexStartAppList = 100,
-} FlipStoreSubmenuIndex;
-
-// Define a single view for our FlipStore application
-typedef enum
-{
-    //
-    FlipStoreViewSubmenu,         // The submenu
-    FlipStoreViewSubmenuOptions,  // The submenu options
-                                  //
-    FlipStoreViewAbout,           // The about screen
-    FlipStoreViewSettings,        // The settings screen
-    FlipStoreViewTextInput,       // The text input screen
-                                  //
-    FlipStoreViewAppList,         // The app list screen
-    FlipStoreViewFirmwares,       // The firmwares screen (submenu)
-    FlipStoreViewVGMFirmwares,    // The VGM firmwares screen (submenu)
-    FlipStoreViewAGithub,         // The GitHub repository screen
-                                  //
-    FlipStoreViewFirmwareDialog,  // The firmware view (DialogEx) of the selected firmware
-                                  //
-    FlipStoreViewAppInfo,         // The app info screen (widget) of the selected app
-    FlipStoreViewAppDownload,     // The app download screen (widget) of the selected app
-    FlipStoreViewAppDelete,       // The app delete screen (DialogEx) of the selected app
-                                  //
-    FlipStoreViewAppListCategory, // the app list screen for each category
-                                  //
-                                  //
-    FlipStoreViewWidgetResult,    // The text box that displays the random fact
-    FlipStoreViewLoader,          // The loader screen retrieves data from the internet
-} FlipStoreView;
-
-// Each screen will have its own view
-typedef struct
-{
-    View *view_loader;
-    Widget *widget_result;
-    //
-    ViewDispatcher *view_dispatcher; // Switches between our views
-    View *view_app_info;             // The app info screen (view) of the selected app
-    //
-    DialogEx *dialog_firmware; // The dialog for installing a firmware
-    //
-    Submenu *submenu_main; // The submenu (main)
-    //
-    Submenu *submenu_options;             // The submenu (options)
-    Submenu *submenu_app_list;            // The submenu (app list) for the selected category
-    Submenu *submenu_firmwares;           // The submenu (firmwares)
-    Submenu *submenu_vgm_firmwares;       // The submenu (VGM firmwares)
-    Submenu *submenu_app_list_category;   // The submenu (app list) for each category
-    Widget *widget_about;                 // The widget
-    VariableItemList *variable_item_list; // The variable item list (settngs)
-    VariableItem *variable_item_ssid;     // The variable item
-    VariableItem *variable_item_pass;     // The variable item
-    //
-    UART_TextInput *uart_text_input;      // The text input
-    char *uart_text_input_buffer;         // Buffer for the text input
-    char *uart_text_input_temp_buffer;    // Temporary buffer for the text input
-    uint32_t uart_text_input_buffer_size; // Size of the text input buffer
-} FlipStoreApp;
-
-void flip_store_app_free(FlipStoreApp *app);
-
-#endif // FLIP_STORE_E_H

+ 0 - 1826
flipper_http/flipper_http.c

@@ -1,1826 +0,0 @@
-// Description: Flipper HTTP API (For use with Flipper Zero and the FlipperHTTP flash: https://github.com/jblanked/FlipperHTTP)
-// License: MIT
-// Author: JBlanked
-// File: flipper_http.c
-#include <flipper_http/flipper_http.h> // change this to where flipper_http.h is located
-
-// Function to append received data to file
-// make sure to initialize the file path before calling this function
-bool flipper_http_append_to_file(
-    const void *data,
-    size_t data_size,
-    bool start_new_file,
-    char *file_path)
-{
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    File *file = storage_file_alloc(storage);
-
-    if (start_new_file)
-    {
-        // Delete the file if it already exists
-        if (storage_file_exists(storage, file_path))
-        {
-            if (!storage_simply_remove_recursive(storage, file_path))
-            {
-                FURI_LOG_E(HTTP_TAG, "Failed to delete file: %s", file_path);
-                storage_file_free(file);
-                furi_record_close(RECORD_STORAGE);
-                return false;
-            }
-        }
-        // Open the file in write mode
-        if (!storage_file_open(file, file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS))
-        {
-            FURI_LOG_E(HTTP_TAG, "Failed to open file for writing: %s", file_path);
-            storage_file_free(file);
-            furi_record_close(RECORD_STORAGE);
-            return false;
-        }
-    }
-    else
-    {
-        // Open the file in append mode
-        if (!storage_file_open(file, file_path, FSAM_WRITE, FSOM_OPEN_APPEND))
-        {
-            FURI_LOG_E(HTTP_TAG, "Failed to open file for appending: %s", file_path);
-            storage_file_free(file);
-            furi_record_close(RECORD_STORAGE);
-            return false;
-        }
-    }
-
-    // Write the data to the file
-    if (storage_file_write(file, data, data_size) != data_size)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to append data to file");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
-
-    storage_file_close(file);
-    storage_file_free(file);
-    furi_record_close(RECORD_STORAGE);
-    return true;
-}
-
-FuriString *flipper_http_load_from_file(char *file_path)
-{
-    // Open the storage record
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    if (!storage)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to open storage record");
-        return NULL;
-    }
-
-    // Allocate a file handle
-    File *file = storage_file_alloc(storage);
-    if (!file)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate storage file");
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-
-    // Open the file for reading
-    if (!storage_file_open(file, file_path, FSAM_READ, FSOM_OPEN_EXISTING))
-    {
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        FURI_LOG_E(HTTP_TAG, "Failed to open file for reading: %s", file_path);
-        return NULL;
-    }
-
-    // Allocate a FuriString to hold the received data
-    FuriString *str_result = furi_string_alloc();
-    if (!str_result)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate FuriString");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-
-    // Reset the FuriString to ensure it's empty before reading
-    furi_string_reset(str_result);
-
-    if (memmgr_get_free_heap() < MAX_FILE_SHOW)
-    {
-        FURI_LOG_E(HTTP_TAG, "Not enough heap to read file.");
-        furi_string_free(str_result);
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-
-    // Define a buffer to hold the read data
-    uint8_t *buffer = (uint8_t *)malloc(MAX_FILE_SHOW);
-    if (!buffer)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate buffer");
-        furi_string_free(str_result);
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-
-    // Read data into the buffer
-    size_t read_count = storage_file_read(file, buffer, MAX_FILE_SHOW);
-    if (storage_file_get_error(file) != FSE_OK)
-    {
-        FURI_LOG_E(HTTP_TAG, "Error reading from file.");
-        furi_string_free(str_result);
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-
-    // Append each byte to the FuriString
-    for (size_t i = 0; i < read_count; i++)
-    {
-        furi_string_push_back(str_result, buffer[i]);
-    }
-
-    // Clean up
-    storage_file_close(file);
-    storage_file_free(file);
-    furi_record_close(RECORD_STORAGE);
-    free(buffer);
-    return str_result;
-}
-
-FuriString *flipper_http_load_from_file_with_limit(char *file_path, size_t limit)
-{
-    // Open the storage record
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-    if (!storage)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to open storage record");
-        return NULL;
-    }
-
-    // Allocate a file handle
-    File *file = storage_file_alloc(storage);
-    if (!file)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate storage file");
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-
-    // Open the file for reading
-    if (!storage_file_open(file, file_path, FSAM_READ, FSOM_OPEN_EXISTING))
-    {
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        FURI_LOG_E(HTTP_TAG, "Failed to open file for reading: %s", file_path);
-        return NULL;
-    }
-
-    if (memmgr_get_free_heap() < limit)
-    {
-        FURI_LOG_E(HTTP_TAG, "Not enough heap to read file.");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-
-    // Allocate a buffer to hold the read data
-    uint8_t *buffer = (uint8_t *)malloc(limit);
-    if (!buffer)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate buffer");
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-
-    // Allocate a FuriString with preallocated capacity
-    FuriString *str_result = furi_string_alloc();
-    if (!str_result)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate FuriString");
-        free(buffer);
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-    furi_string_reserve(str_result, limit);
-
-    // Read data into the buffer
-    size_t read_count = storage_file_read(file, buffer, limit);
-    if (storage_file_get_error(file) != FSE_OK)
-    {
-        FURI_LOG_E(HTTP_TAG, "Error reading from file.");
-        furi_string_free(str_result);
-        free(buffer);
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-    if (read_count == 0)
-    {
-        FURI_LOG_E(HTTP_TAG, "No data read from file.");
-        furi_string_free(str_result);
-        free(buffer);
-        storage_file_close(file);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        return NULL;
-    }
-
-    // Append the entire buffer to FuriString in one operation
-    furi_string_cat_str(str_result, (char *)buffer);
-
-    // Clean up
-    storage_file_close(file);
-    storage_file_free(file);
-    furi_record_close(RECORD_STORAGE);
-    free(buffer);
-    return str_result;
-}
-
-// UART worker thread
-/**
- * @brief      Worker thread to handle UART data asynchronously.
- * @return     0
- * @param      context   The FlipperHTTP context.
- * @note       This function will handle received data asynchronously via the callback.
- */
-// UART worker thread
-int32_t flipper_http_worker(void *context)
-{
-    if (!context)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return -1;
-    }
-    FlipperHTTP *fhttp = (FlipperHTTP *)context;
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return -1;
-    }
-    size_t rx_line_pos = 0;
-
-    while (1)
-    {
-        uint32_t events = furi_thread_flags_wait(
-            WorkerEvtStop | WorkerEvtRxDone, FuriFlagWaitAny, FuriWaitForever);
-        if (events & WorkerEvtStop)
-        {
-            break;
-        }
-        if (events & WorkerEvtRxDone)
-        {
-            // Continuously read from the stream buffer until it's empty
-            while (!furi_stream_buffer_is_empty(fhttp->flipper_http_stream))
-            {
-                // Read one byte at a time
-                char c = 0;
-                size_t received = furi_stream_buffer_receive(fhttp->flipper_http_stream, &c, 1, 0);
-
-                if (received == 0)
-                {
-                    // No more data to read
-                    break;
-                }
-
-                // Append the received byte to the file if saving is enabled
-                if (fhttp->save_bytes)
-                {
-                    // Add byte to the buffer
-                    fhttp->file_buffer[fhttp->file_buffer_len++] = c;
-                    // Write to file if buffer is full
-                    if (fhttp->file_buffer_len >= FILE_BUFFER_SIZE)
-                    {
-                        if (!flipper_http_append_to_file(
-                                fhttp->file_buffer,
-                                fhttp->file_buffer_len,
-                                fhttp->just_started_bytes,
-                                fhttp->file_path))
-                        {
-                            FURI_LOG_E(HTTP_TAG, "Failed to append data to file");
-                        }
-                        fhttp->file_buffer_len = 0;
-                        fhttp->just_started_bytes = false;
-                    }
-                }
-
-                // Handle line buffering only if callback is set (text data)
-                if (fhttp->handle_rx_line_cb)
-                {
-                    // Handle line buffering
-                    if (c == '\n' || rx_line_pos >= RX_LINE_BUFFER_SIZE - 1)
-                    {
-                        fhttp->rx_line_buffer[rx_line_pos] = '\0'; // Null-terminate the line
-
-                        // Invoke the callback with the complete line
-                        fhttp->handle_rx_line_cb(fhttp->rx_line_buffer, fhttp->callback_context);
-
-                        // Reset the line buffer position
-                        rx_line_pos = 0;
-                    }
-                    else
-                    {
-                        fhttp->rx_line_buffer[rx_line_pos++] = c; // Add character to the line buffer
-                    }
-                }
-            }
-        }
-    }
-
-    return 0;
-}
-// Timer callback function
-/**
- * @brief      Callback function for the GET timeout timer.
- * @return     0
- * @param      context   The FlipperHTTP context.
- * @note       This function will be called when the GET request times out.
- */
-void get_timeout_timer_callback(void *context)
-{
-    FlipperHTTP *fhttp = (FlipperHTTP *)context;
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return;
-    }
-    FURI_LOG_E(HTTP_TAG, "Timeout reached without receiving the end.");
-
-    // Reset the state
-    fhttp->started_receiving_get = false;
-    fhttp->started_receiving_post = false;
-    fhttp->started_receiving_put = false;
-    fhttp->started_receiving_delete = false;
-
-    // Update UART state
-    fhttp->state = ISSUE;
-}
-
-// UART RX Handler Callback (Interrupt Context)
-/**
- * @brief      A private callback function to handle received data asynchronously.
- * @return     void
- * @param      handle    The UART handle.
- * @param      event     The event type.
- * @param      context   The FlipperHTTP context.
- * @note       This function will handle received data asynchronously via the callback.
- */
-void _flipper_http_rx_callback(
-    FuriHalSerialHandle *handle,
-    FuriHalSerialRxEvent event,
-    void *context)
-{
-    FlipperHTTP *fhttp = (FlipperHTTP *)context;
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return;
-    }
-    if (event == FuriHalSerialRxEventData)
-    {
-        uint8_t data = furi_hal_serial_async_rx(handle);
-        furi_stream_buffer_send(fhttp->flipper_http_stream, &data, 1, 0);
-        furi_thread_flags_set(fhttp->rx_thread_id, WorkerEvtRxDone);
-    }
-}
-
-// UART initialization function
-/**
- * @brief      Initialize UART.
- * @return     FlipperHTTP context if the UART was initialized successfully, NULL otherwise.
- * @note       The received data will be handled asynchronously via the callback.
- */
-FlipperHTTP *flipper_http_alloc()
-{
-    FlipperHTTP *fhttp = (FlipperHTTP *)malloc(sizeof(FlipperHTTP));
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate FlipperHTTP.");
-        return NULL;
-    }
-    memset(fhttp, 0, sizeof(FlipperHTTP)); // Initialize allocated memory to zero
-
-    fhttp->flipper_http_stream = furi_stream_buffer_alloc(RX_BUF_SIZE, 1);
-    if (!fhttp->flipper_http_stream)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate UART stream buffer.");
-        free(fhttp);
-        return NULL;
-    }
-
-    fhttp->rx_thread = furi_thread_alloc();
-    if (!fhttp->rx_thread)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate UART thread.");
-        furi_stream_buffer_free(fhttp->flipper_http_stream);
-        free(fhttp);
-        return NULL;
-    }
-
-    furi_thread_set_name(fhttp->rx_thread, "FlipperHTTP_RxThread");
-    furi_thread_set_stack_size(fhttp->rx_thread, 1024);
-    furi_thread_set_context(fhttp->rx_thread, fhttp); // Corrected context
-    furi_thread_set_callback(fhttp->rx_thread, flipper_http_worker);
-
-    fhttp->handle_rx_line_cb = flipper_http_rx_callback;
-    fhttp->callback_context = fhttp;
-
-    furi_thread_start(fhttp->rx_thread);
-    fhttp->rx_thread_id = furi_thread_get_id(fhttp->rx_thread);
-
-    // Handle when the UART control is busy to avoid furi_check failed
-    if (furi_hal_serial_control_is_busy(UART_CH))
-    {
-        FURI_LOG_E(HTTP_TAG, "UART control is busy.");
-        // Cleanup resources
-        furi_thread_flags_set(fhttp->rx_thread_id, WorkerEvtStop);
-        furi_thread_join(fhttp->rx_thread);
-        furi_thread_free(fhttp->rx_thread);
-        furi_stream_buffer_free(fhttp->flipper_http_stream);
-        free(fhttp);
-        return NULL;
-    }
-
-    fhttp->serial_handle = furi_hal_serial_control_acquire(UART_CH);
-    if (!fhttp->serial_handle)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to acquire UART control - handle is NULL");
-        // Cleanup resources
-        furi_thread_flags_set(fhttp->rx_thread_id, WorkerEvtStop);
-        furi_thread_join(fhttp->rx_thread);
-        furi_thread_free(fhttp->rx_thread);
-        furi_stream_buffer_free(fhttp->flipper_http_stream);
-        free(fhttp);
-        return NULL;
-    }
-
-    // Initialize UART with acquired handle
-    furi_hal_serial_init(fhttp->serial_handle, BAUDRATE);
-
-    // Enable RX direction
-    furi_hal_serial_enable_direction(fhttp->serial_handle, FuriHalSerialDirectionRx);
-
-    // Start asynchronous RX with the corrected callback and context
-    furi_hal_serial_async_rx_start(fhttp->serial_handle, _flipper_http_rx_callback, fhttp, false); // Corrected context
-
-    // Wait for the TX to complete to ensure UART is ready
-    furi_hal_serial_tx_wait_complete(fhttp->serial_handle);
-
-    // Allocate the timer for handling timeouts
-    fhttp->get_timeout_timer = furi_timer_alloc(
-        get_timeout_timer_callback, // Callback function
-        FuriTimerTypeOnce,          // One-shot timer
-        fhttp                       // Corrected context
-    );
-
-    if (!fhttp->get_timeout_timer)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate HTTP request timeout timer.");
-        // Cleanup resources
-        furi_hal_serial_async_rx_stop(fhttp->serial_handle);
-        furi_hal_serial_disable_direction(fhttp->serial_handle, FuriHalSerialDirectionRx);
-        furi_hal_serial_control_release(fhttp->serial_handle);
-        furi_hal_serial_deinit(fhttp->serial_handle);
-        furi_thread_flags_set(fhttp->rx_thread_id, WorkerEvtStop);
-        furi_thread_join(fhttp->rx_thread);
-        furi_thread_free(fhttp->rx_thread);
-        furi_stream_buffer_free(fhttp->flipper_http_stream);
-        free(fhttp);
-        return NULL;
-    }
-
-    // Set the timer thread priority if needed
-    furi_timer_set_thread_priority(FuriTimerThreadPriorityElevated);
-
-    fhttp->last_response = (char *)malloc(RX_BUF_SIZE);
-    if (!fhttp->last_response)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate memory for last_response.");
-        // Cleanup resources
-        furi_timer_free(fhttp->get_timeout_timer);
-        furi_hal_serial_async_rx_stop(fhttp->serial_handle);
-        furi_hal_serial_disable_direction(fhttp->serial_handle, FuriHalSerialDirectionRx);
-        furi_hal_serial_control_release(fhttp->serial_handle);
-        furi_hal_serial_deinit(fhttp->serial_handle);
-        furi_thread_flags_set(fhttp->rx_thread_id, WorkerEvtStop);
-        furi_thread_join(fhttp->rx_thread);
-        furi_thread_free(fhttp->rx_thread);
-        furi_stream_buffer_free(fhttp->flipper_http_stream);
-        free(fhttp);
-        return NULL;
-    }
-    memset(fhttp->last_response, 0, RX_BUF_SIZE); // Initialize last_response
-
-    fhttp->state = IDLE;
-
-    // FURI_LOG_I(HTTP_TAG, "UART initialized successfully.");
-    return fhttp;
-}
-
-// Deinitialize UART
-/**
- * @brief      Deinitialize UART.
- * @return     void
- * @param fhttp The FlipperHTTP context
- * @note       This function will stop the asynchronous RX, release the serial handle, and free the resources.
- */
-void flipper_http_free(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return;
-    }
-    if (fhttp->serial_handle == NULL)
-    {
-        FURI_LOG_E(HTTP_TAG, "UART handle is NULL. Already deinitialized?");
-        return;
-    }
-    // Stop asynchronous RX
-    furi_hal_serial_async_rx_stop(fhttp->serial_handle);
-
-    // Release and deinitialize the serial handle
-    furi_hal_serial_disable_direction(fhttp->serial_handle, FuriHalSerialDirectionRx);
-    furi_hal_serial_control_release(fhttp->serial_handle);
-    furi_hal_serial_deinit(fhttp->serial_handle);
-
-    // Signal the worker thread to stop
-    furi_thread_flags_set(fhttp->rx_thread_id, WorkerEvtStop);
-    // Wait for the thread to finish
-    furi_thread_join(fhttp->rx_thread);
-    // Free the thread resources
-    furi_thread_free(fhttp->rx_thread);
-
-    // Free the stream buffer
-    furi_stream_buffer_free(fhttp->flipper_http_stream);
-
-    // Free the timer
-    if (fhttp->get_timeout_timer)
-    {
-        furi_timer_free(fhttp->get_timeout_timer);
-        fhttp->get_timeout_timer = NULL;
-    }
-
-    // Free the last response
-    if (fhttp->last_response)
-    {
-        free(fhttp->last_response);
-        fhttp->last_response = NULL;
-    }
-
-    // Free the FlipperHTTP context
-    free(fhttp);
-    fhttp = NULL;
-
-    // FURI_LOG_I("FlipperHTTP", "UART deinitialized successfully.");
-}
-
-// Function to send data over UART with newline termination
-/**
- * @brief      Send data over UART with newline termination.
- * @return     true if the data was sent successfully, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      data  The data to send over UART.
- * @note       The data will be sent over UART with a newline character appended.
- */
-bool flipper_http_send_data(FlipperHTTP *fhttp, const char *data)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    size_t data_length = strlen(data);
-    if (data_length == 0)
-    {
-        FURI_LOG_E("FlipperHTTP", "Attempted to send empty data.");
-        return false;
-    }
-
-    // Create a buffer with data + '\n'
-    size_t send_length = data_length + 1; // +1 for '\n'
-    if (send_length > 256)
-    { // Ensure buffer size is sufficient
-        FURI_LOG_E("FlipperHTTP", "Data too long to send over FHTTP->");
-        return false;
-    }
-
-    char send_buffer[257]; // 256 + 1 for safety
-    strncpy(send_buffer, data, 256);
-    send_buffer[data_length] = '\n';     // Append newline
-    send_buffer[data_length + 1] = '\0'; // Null-terminate
-
-    if (fhttp->state == INACTIVE && ((strstr(send_buffer, "[PING]") == NULL) &&
-                                     (strstr(send_buffer, "[WIFI/CONNECT]") == NULL)))
-    {
-        FURI_LOG_E("FlipperHTTP", "Cannot send data while INACTIVE.");
-        fhttp->last_response = "Cannot send data while INACTIVE.";
-        return false;
-    }
-
-    fhttp->state = SENDING;
-    furi_hal_serial_tx(fhttp->serial_handle, (const uint8_t *)send_buffer, send_length);
-
-    // Uncomment below line to log the data sent over UART
-    // FURI_LOG_I("FlipperHTTP", "Sent data over UART: %s", send_buffer);
-    fhttp->state = IDLE;
-    return true;
-}
-
-// Function to send a PING request
-/**
- * @brief      Send a PING request to check if the Wifi Dev Board is connected.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- * @note       This is best used to check if the Wifi Dev Board is connected.
- * @note       The state will remain INACTIVE until a PONG is received.
- */
-bool flipper_http_ping(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    const char *command = "[PING]";
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send PING command.");
-        return false;
-    }
-    // set state as INACTIVE to be made IDLE if PONG is received
-    fhttp->state = INACTIVE;
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to list available commands
-/**
- * @brief      Send a command to list available commands.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_list_commands(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    const char *command = "[LIST]";
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send LIST command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to turn on the LED
-/**
- * @brief      Allow the LED to display while processing.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_led_on(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    const char *command = "[LED/ON]";
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send LED ON command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to turn off the LED
-/**
- * @brief      Disable the LED from displaying while processing.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_led_off(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    const char *command = "[LED/OFF]";
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send LED OFF command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to parse JSON data
-/**
- * @brief      Parse JSON data.
- * @return     true if the JSON data was parsed successfully, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      key       The key to parse from the JSON data.
- * @param      json_data The JSON data to parse.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_parse_json(FlipperHTTP *fhttp, const char *key, const char *json_data)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (!key || !json_data)
-    {
-        FURI_LOG_E("FlipperHTTP", "Invalid arguments provided to flipper_http_parse_json.");
-        return false;
-    }
-
-    char buffer[256];
-    int ret =
-        snprintf(buffer, sizeof(buffer), "[PARSE]{\"key\":\"%s\",\"json\":%s}", key, json_data);
-    if (ret < 0 || ret >= (int)sizeof(buffer))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to format JSON parse command.");
-        return false;
-    }
-
-    if (!flipper_http_send_data(fhttp, buffer))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send JSON parse command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to parse JSON array data
-/**
- * @brief      Parse JSON array data.
- * @return     true if the JSON array data was parsed successfully, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      key       The key to parse from the JSON array data.
- * @param      index     The index to parse from the JSON array data.
- * @param      json_data The JSON array data to parse.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_parse_json_array(FlipperHTTP *fhttp, const char *key, int index, const char *json_data)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (!key || !json_data)
-    {
-        FURI_LOG_E("FlipperHTTP", "Invalid arguments provided to flipper_http_parse_json_array.");
-        return false;
-    }
-
-    char buffer[256];
-    int ret = snprintf(
-        buffer,
-        sizeof(buffer),
-        "[PARSE/ARRAY]{\"key\":\"%s\",\"index\":%d,\"json\":%s}",
-        key,
-        index,
-        json_data);
-    if (ret < 0 || ret >= (int)sizeof(buffer))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to format JSON parse array command.");
-        return false;
-    }
-
-    if (!flipper_http_send_data(fhttp, buffer))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send JSON parse array command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to scan for WiFi networks
-/**
- * @brief      Send a command to scan for WiFi networks.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_scan_wifi(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    const char *command = "[WIFI/SCAN]";
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send WiFi scan command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to save WiFi settings (returns true if successful)
-/**
- * @brief      Send a command to save WiFi settings.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_save_wifi(FlipperHTTP *fhttp, const char *ssid, const char *password)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (!ssid || !password)
-    {
-        FURI_LOG_E("FlipperHTTP", "Invalid arguments provided to flipper_http_save_wifi.");
-        return false;
-    }
-    char buffer[256];
-    int ret = snprintf(
-        buffer, sizeof(buffer), "[WIFI/SAVE]{\"ssid\":\"%s\",\"password\":\"%s\"}", ssid, password);
-    if (ret < 0 || ret >= (int)sizeof(buffer))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to format WiFi save command.");
-        return false;
-    }
-
-    if (!flipper_http_send_data(fhttp, buffer))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send WiFi save command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to get IP address of WiFi Devboard
-/**
- * @brief      Send a command to get the IP address of the WiFi Devboard
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_ip_address(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    const char *command = "[IP/ADDRESS]";
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send IP address command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to get IP address of the connected WiFi network
-/**
- * @brief      Send a command to get the IP address of the connected WiFi network.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_ip_wifi(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    const char *command = "[WIFI/IP]";
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send WiFi IP command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to disconnect from WiFi (returns true if successful)
-/**
- * @brief      Send a command to disconnect from WiFi.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_disconnect_wifi(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    const char *command = "[WIFI/DISCONNECT]";
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send WiFi disconnect command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to connect to WiFi (returns true if successful)
-/**
- * @brief      Send a command to connect to WiFi.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_connect_wifi(FlipperHTTP *fhttp)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    const char *command = "[WIFI/CONNECT]";
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send WiFi connect command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to send a GET request
-/**
- * @brief      Send a GET request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the GET request to.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_get_request(FlipperHTTP *fhttp, const char *url)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (!url)
-    {
-        FURI_LOG_E("FlipperHTTP", "Invalid arguments provided to flipper_http_get_request.");
-        return false;
-    }
-
-    // Prepare GET request command
-    char command[256];
-    int ret = snprintf(command, sizeof(command), "[GET]%s", url);
-    if (ret < 0 || ret >= (int)sizeof(command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to format GET request command.");
-        return false;
-    }
-
-    // Send GET request via UART
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send GET request command.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to send a GET request with headers
-/**
- * @brief      Send a GET request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the GET request to.
- * @param      headers  The headers to send with the GET request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_get_request_with_headers(FlipperHTTP *fhttp, const char *url, const char *headers)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (!url || !headers)
-    {
-        FURI_LOG_E(
-            "FlipperHTTP", "Invalid arguments provided to flipper_http_get_request_with_headers.");
-        return false;
-    }
-
-    // Prepare GET request command with headers
-    char command[256];
-    int ret = snprintf(
-        command, sizeof(command), "[GET/HTTP]{\"url\":\"%s\",\"headers\":%s}", url, headers);
-    if (ret < 0 || ret >= (int)sizeof(command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to format GET request command with headers.");
-        return false;
-    }
-
-    // Send GET request via UART
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send GET request command with headers.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to send a GET request with headers and return bytes
-/**
- * @brief      Send a GET request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the GET request to.
- * @param      headers  The headers to send with the GET request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_get_request_bytes(FlipperHTTP *fhttp, const char *url, const char *headers)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (!url || !headers)
-    {
-        FURI_LOG_E("FlipperHTTP", "Invalid arguments provided to flipper_http_get_request_bytes.");
-        return false;
-    }
-
-    // Prepare GET request command with headers
-    char command[256];
-    int ret = snprintf(
-        command, sizeof(command), "[GET/BYTES]{\"url\":\"%s\",\"headers\":%s}", url, headers);
-    if (ret < 0 || ret >= (int)sizeof(command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to format GET request command with headers.");
-        return false;
-    }
-
-    // Send GET request via UART
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send GET request command with headers.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to send a POST request with headers
-/**
- * @brief      Send a POST request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the POST request to.
- * @param      headers  The headers to send with the POST request.
- * @param      data  The data to send with the POST request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_post_request_with_headers(
-    FlipperHTTP *fhttp,
-    const char *url,
-    const char *headers,
-    const char *payload)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (!url || !headers || !payload)
-    {
-        FURI_LOG_E(
-            "FlipperHTTP",
-            "Invalid arguments provided to flipper_http_post_request_with_headers.");
-        return false;
-    }
-
-    // Prepare POST request command with headers and data
-    char command[256];
-    int ret = snprintf(
-        command,
-        sizeof(command),
-        "[POST/HTTP]{\"url\":\"%s\",\"headers\":%s,\"payload\":%s}",
-        url,
-        headers,
-        payload);
-    if (ret < 0 || ret >= (int)sizeof(command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to format POST request command with headers and data.");
-        return false;
-    }
-
-    // Send POST request via UART
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send POST request command with headers and data.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to send a POST request with headers and return bytes
-/**
- * @brief      Send a POST request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the POST request to.
- * @param      headers  The headers to send with the POST request.
- * @param      payload  The data to send with the POST request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_post_request_bytes(FlipperHTTP *fhttp, const char *url, const char *headers, const char *payload)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (!url || !headers || !payload)
-    {
-        FURI_LOG_E(
-            "FlipperHTTP", "Invalid arguments provided to flipper_http_post_request_bytes.");
-        return false;
-    }
-
-    // Prepare POST request command with headers and data
-    char command[256];
-    int ret = snprintf(
-        command,
-        sizeof(command),
-        "[POST/BYTES]{\"url\":\"%s\",\"headers\":%s,\"payload\":%s}",
-        url,
-        headers,
-        payload);
-    if (ret < 0 || ret >= (int)sizeof(command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to format POST request command with headers and data.");
-        return false;
-    }
-
-    // Send POST request via UART
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send POST request command with headers and data.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to send a PUT request with headers
-/**
- * @brief      Send a PUT request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the PUT request to.
- * @param      headers  The headers to send with the PUT request.
- * @param      data  The data to send with the PUT request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_put_request_with_headers(
-    FlipperHTTP *fhttp,
-    const char *url,
-    const char *headers,
-    const char *payload)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (!url || !headers || !payload)
-    {
-        FURI_LOG_E(
-            "FlipperHTTP", "Invalid arguments provided to flipper_http_put_request_with_headers.");
-        return false;
-    }
-
-    // Prepare PUT request command with headers and data
-    char command[256];
-    int ret = snprintf(
-        command,
-        sizeof(command),
-        "[PUT/HTTP]{\"url\":\"%s\",\"headers\":%s,\"payload\":%s}",
-        url,
-        headers,
-        payload);
-    if (ret < 0 || ret >= (int)sizeof(command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to format PUT request command with headers and data.");
-        return false;
-    }
-
-    // Send PUT request via UART
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send PUT request command with headers and data.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-
-// Function to send a DELETE request with headers
-/**
- * @brief      Send a DELETE request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the DELETE request to.
- * @param      headers  The headers to send with the DELETE request.
- * @param      data  The data to send with the DELETE request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_delete_request_with_headers(
-    FlipperHTTP *fhttp,
-    const char *url,
-    const char *headers,
-    const char *payload)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (!url || !headers || !payload)
-    {
-        FURI_LOG_E(
-            "FlipperHTTP",
-            "Invalid arguments provided to flipper_http_delete_request_with_headers.");
-        return false;
-    }
-
-    // Prepare DELETE request command with headers and data
-    char command[256];
-    int ret = snprintf(
-        command,
-        sizeof(command),
-        "[DELETE/HTTP]{\"url\":\"%s\",\"headers\":%s,\"payload\":%s}",
-        url,
-        headers,
-        payload);
-    if (ret < 0 || ret >= (int)sizeof(command))
-    {
-        FURI_LOG_E(
-            "FlipperHTTP", "Failed to format DELETE request command with headers and data.");
-        return false;
-    }
-
-    // Send DELETE request via UART
-    if (!flipper_http_send_data(fhttp, command))
-    {
-        FURI_LOG_E("FlipperHTTP", "Failed to send DELETE request command with headers and data.");
-        return false;
-    }
-
-    // The response will be handled asynchronously via the callback
-    return true;
-}
-// Function to trim leading and trailing spaces and newlines from a constant string
-static char *trim(const char *str)
-{
-    const char *end;
-    char *trimmed_str;
-    size_t len;
-
-    // Trim leading space
-    while (isspace((unsigned char)*str))
-        str++;
-
-    // All spaces?
-    if (*str == 0)
-        return strdup(""); // Return an empty string if all spaces
-
-    // Trim trailing space
-    end = str + strlen(str) - 1;
-    while (end > str && isspace((unsigned char)*end))
-        end--;
-
-    // Set length for the trimmed string
-    len = end - str + 1;
-
-    // Allocate space for the trimmed string and null terminator
-    trimmed_str = (char *)malloc(len + 1);
-    if (trimmed_str == NULL)
-    {
-        return NULL; // Handle memory allocation failure
-    }
-
-    // Copy the trimmed part of the string into trimmed_str
-    strncpy(trimmed_str, str, len);
-    trimmed_str[len] = '\0'; // Null terminate the string
-
-    return trimmed_str;
-}
-
-// Function to handle received data asynchronously
-/**
- * @brief      Callback function to handle received data asynchronously.
- * @return     void
- * @param      line     The received line.
- * @param      context  The FlipperHTTP context.
- * @note       The received data will be handled asynchronously via the callback and handles the state of the UART.
- */
-void flipper_http_rx_callback(const char *line, void *context)
-{
-    FlipperHTTP *fhttp = (FlipperHTTP *)context;
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return;
-    }
-    if (!line)
-    {
-        FURI_LOG_E(HTTP_TAG, "Invalid arguments provided to flipper_http_rx_callback.");
-        return;
-    }
-
-    // Trim the received line to check if it's empty
-    char *trimmed_line = trim(line);
-    if (trimmed_line != NULL && trimmed_line[0] != '\0')
-    {
-        // if the line is not [GET/END] or [POST/END] or [PUT/END] or [DELETE/END]
-        if (strstr(trimmed_line, "[GET/END]") == NULL &&
-            strstr(trimmed_line, "[POST/END]") == NULL &&
-            strstr(trimmed_line, "[PUT/END]") == NULL &&
-            strstr(trimmed_line, "[DELETE/END]") == NULL)
-        {
-            strncpy(fhttp->last_response, trimmed_line, RX_BUF_SIZE);
-        }
-    }
-    free(trimmed_line); // Free the allocated memory for trimmed_line
-
-    if (fhttp->state != INACTIVE && fhttp->state != ISSUE)
-    {
-        fhttp->state = RECEIVING;
-    }
-
-    // Uncomment below line to log the data received over UART
-    // FURI_LOG_I(HTTP_TAG, "Received UART line: %s", line);
-
-    // Check if we've started receiving data from a GET request
-    if (fhttp->started_receiving_get)
-    {
-        // Restart the timeout timer each time new data is received
-        furi_timer_restart(fhttp->get_timeout_timer, TIMEOUT_DURATION_TICKS);
-
-        if (strstr(line, "[GET/END]") != NULL)
-        {
-            FURI_LOG_I(HTTP_TAG, "GET request completed.");
-            // Stop the timer since we've completed the GET request
-            furi_timer_stop(fhttp->get_timeout_timer);
-            fhttp->started_receiving_get = false;
-            fhttp->just_started_get = false;
-            fhttp->state = IDLE;
-            fhttp->save_bytes = false;
-            fhttp->save_received_data = false;
-
-            if (fhttp->is_bytes_request)
-            {
-                // Search for the binary marker `[GET/END]` in the file buffer
-                const char marker[] = "[GET/END]";
-                const size_t marker_len = sizeof(marker) - 1; // Exclude null terminator
-
-                for (size_t i = 0; i <= fhttp->file_buffer_len - marker_len; i++)
-                {
-                    // Check if the marker is found
-                    if (memcmp(&fhttp->file_buffer[i], marker, marker_len) == 0)
-                    {
-                        // Remove the marker by shifting the remaining data left
-                        size_t remaining_len = fhttp->file_buffer_len - (i + marker_len);
-                        memmove(&fhttp->file_buffer[i], &fhttp->file_buffer[i + marker_len], remaining_len);
-                        fhttp->file_buffer_len -= marker_len;
-                        break;
-                    }
-                }
-
-                // If there is data left in the buffer, append it to the file
-                if (fhttp->file_buffer_len > 0)
-                {
-                    if (!flipper_http_append_to_file(fhttp->file_buffer, fhttp->file_buffer_len, false, fhttp->file_path))
-                    {
-                        FURI_LOG_E(HTTP_TAG, "Failed to append data to file.");
-                    }
-                    fhttp->file_buffer_len = 0;
-                }
-            }
-
-            fhttp->is_bytes_request = false;
-            return;
-        }
-
-        // Append the new line to the existing data
-        if (fhttp->save_received_data &&
-            !flipper_http_append_to_file(
-                line, strlen(line), !fhttp->just_started_get, fhttp->file_path))
-        {
-            FURI_LOG_E(HTTP_TAG, "Failed to append data to file.");
-            fhttp->started_receiving_get = false;
-            fhttp->just_started_get = false;
-            fhttp->state = IDLE;
-            return;
-        }
-
-        if (!fhttp->just_started_get)
-        {
-            fhttp->just_started_get = true;
-        }
-        return;
-    }
-
-    // Check if we've started receiving data from a POST request
-    else if (fhttp->started_receiving_post)
-    {
-        // Restart the timeout timer each time new data is received
-        furi_timer_restart(fhttp->get_timeout_timer, TIMEOUT_DURATION_TICKS);
-
-        if (strstr(line, "[POST/END]") != NULL)
-        {
-            FURI_LOG_I(HTTP_TAG, "POST request completed.");
-            // Stop the timer since we've completed the POST request
-            furi_timer_stop(fhttp->get_timeout_timer);
-            fhttp->started_receiving_post = false;
-            fhttp->just_started_post = false;
-            fhttp->state = IDLE;
-            fhttp->save_bytes = false;
-            fhttp->save_received_data = false;
-
-            if (fhttp->is_bytes_request)
-            {
-                // Search for the binary marker `[POST/END]` in the file buffer
-                const char marker[] = "[POST/END]";
-                const size_t marker_len = sizeof(marker) - 1; // Exclude null terminator
-
-                for (size_t i = 0; i <= fhttp->file_buffer_len - marker_len; i++)
-                {
-                    // Check if the marker is found
-                    if (memcmp(&fhttp->file_buffer[i], marker, marker_len) == 0)
-                    {
-                        // Remove the marker by shifting the remaining data left
-                        size_t remaining_len = fhttp->file_buffer_len - (i + marker_len);
-                        memmove(&fhttp->file_buffer[i], &fhttp->file_buffer[i + marker_len], remaining_len);
-                        fhttp->file_buffer_len -= marker_len;
-                        break;
-                    }
-                }
-
-                // If there is data left in the buffer, append it to the file
-                if (fhttp->file_buffer_len > 0)
-                {
-                    if (!flipper_http_append_to_file(fhttp->file_buffer, fhttp->file_buffer_len, false, fhttp->file_path))
-                    {
-                        FURI_LOG_E(HTTP_TAG, "Failed to append data to file.");
-                    }
-                    fhttp->file_buffer_len = 0;
-                }
-            }
-
-            fhttp->is_bytes_request = false;
-            return;
-        }
-
-        // Append the new line to the existing data
-        if (fhttp->save_received_data &&
-            !flipper_http_append_to_file(
-                line, strlen(line), !fhttp->just_started_post, fhttp->file_path))
-        {
-            FURI_LOG_E(HTTP_TAG, "Failed to append data to file.");
-            fhttp->started_receiving_post = false;
-            fhttp->just_started_post = false;
-            fhttp->state = IDLE;
-            return;
-        }
-
-        if (!fhttp->just_started_post)
-        {
-            fhttp->just_started_post = true;
-        }
-        return;
-    }
-
-    // Check if we've started receiving data from a PUT request
-    else if (fhttp->started_receiving_put)
-    {
-        // Restart the timeout timer each time new data is received
-        furi_timer_restart(fhttp->get_timeout_timer, TIMEOUT_DURATION_TICKS);
-
-        if (strstr(line, "[PUT/END]") != NULL)
-        {
-            FURI_LOG_I(HTTP_TAG, "PUT request completed.");
-            // Stop the timer since we've completed the PUT request
-            furi_timer_stop(fhttp->get_timeout_timer);
-            fhttp->started_receiving_put = false;
-            fhttp->just_started_put = false;
-            fhttp->state = IDLE;
-            fhttp->save_bytes = false;
-            fhttp->is_bytes_request = false;
-            fhttp->save_received_data = false;
-            return;
-        }
-
-        // Append the new line to the existing data
-        if (fhttp->save_received_data &&
-            !flipper_http_append_to_file(
-                line, strlen(line), !fhttp->just_started_put, fhttp->file_path))
-        {
-            FURI_LOG_E(HTTP_TAG, "Failed to append data to file.");
-            fhttp->started_receiving_put = false;
-            fhttp->just_started_put = false;
-            fhttp->state = IDLE;
-            return;
-        }
-
-        if (!fhttp->just_started_put)
-        {
-            fhttp->just_started_put = true;
-        }
-        return;
-    }
-
-    // Check if we've started receiving data from a DELETE request
-    else if (fhttp->started_receiving_delete)
-    {
-        // Restart the timeout timer each time new data is received
-        furi_timer_restart(fhttp->get_timeout_timer, TIMEOUT_DURATION_TICKS);
-
-        if (strstr(line, "[DELETE/END]") != NULL)
-        {
-            FURI_LOG_I(HTTP_TAG, "DELETE request completed.");
-            // Stop the timer since we've completed the DELETE request
-            furi_timer_stop(fhttp->get_timeout_timer);
-            fhttp->started_receiving_delete = false;
-            fhttp->just_started_delete = false;
-            fhttp->state = IDLE;
-            fhttp->save_bytes = false;
-            fhttp->is_bytes_request = false;
-            fhttp->save_received_data = false;
-            return;
-        }
-
-        // Append the new line to the existing data
-        if (fhttp->save_received_data &&
-            !flipper_http_append_to_file(
-                line, strlen(line), !fhttp->just_started_delete, fhttp->file_path))
-        {
-            FURI_LOG_E(HTTP_TAG, "Failed to append data to file.");
-            fhttp->started_receiving_delete = false;
-            fhttp->just_started_delete = false;
-            fhttp->state = IDLE;
-            return;
-        }
-
-        if (!fhttp->just_started_delete)
-        {
-            fhttp->just_started_delete = true;
-        }
-        return;
-    }
-
-    // Handle different types of responses
-    if (strstr(line, "[SUCCESS]") != NULL || strstr(line, "[CONNECTED]") != NULL)
-    {
-        FURI_LOG_I(HTTP_TAG, "Operation succeeded.");
-    }
-    else if (strstr(line, "[INFO]") != NULL)
-    {
-        FURI_LOG_I(HTTP_TAG, "Received info: %s", line);
-
-        if (fhttp->state == INACTIVE && strstr(line, "[INFO] Already connected to Wifi.") != NULL)
-        {
-            fhttp->state = IDLE;
-        }
-    }
-    else if (strstr(line, "[GET/SUCCESS]") != NULL)
-    {
-        FURI_LOG_I(HTTP_TAG, "GET request succeeded.");
-        fhttp->started_receiving_get = true;
-        furi_timer_start(fhttp->get_timeout_timer, TIMEOUT_DURATION_TICKS);
-        fhttp->state = RECEIVING;
-        // for GET request, save data only if it's a bytes request
-        fhttp->save_bytes = fhttp->is_bytes_request;
-        fhttp->just_started_bytes = true;
-        fhttp->file_buffer_len = 0;
-        return;
-    }
-    else if (strstr(line, "[POST/SUCCESS]") != NULL)
-    {
-        FURI_LOG_I(HTTP_TAG, "POST request succeeded.");
-        fhttp->started_receiving_post = true;
-        furi_timer_start(fhttp->get_timeout_timer, TIMEOUT_DURATION_TICKS);
-        fhttp->state = RECEIVING;
-        // for POST request, save data only if it's a bytes request
-        fhttp->save_bytes = fhttp->is_bytes_request;
-        fhttp->just_started_bytes = true;
-        fhttp->file_buffer_len = 0;
-        return;
-    }
-    else if (strstr(line, "[PUT/SUCCESS]") != NULL)
-    {
-        FURI_LOG_I(HTTP_TAG, "PUT request succeeded.");
-        fhttp->started_receiving_put = true;
-        furi_timer_start(fhttp->get_timeout_timer, TIMEOUT_DURATION_TICKS);
-        fhttp->state = RECEIVING;
-        return;
-    }
-    else if (strstr(line, "[DELETE/SUCCESS]") != NULL)
-    {
-        FURI_LOG_I(HTTP_TAG, "DELETE request succeeded.");
-        fhttp->started_receiving_delete = true;
-        furi_timer_start(fhttp->get_timeout_timer, TIMEOUT_DURATION_TICKS);
-        fhttp->state = RECEIVING;
-        return;
-    }
-    else if (strstr(line, "[DISCONNECTED]") != NULL)
-    {
-        FURI_LOG_I(HTTP_TAG, "WiFi disconnected successfully.");
-    }
-    else if (strstr(line, "[ERROR]") != NULL)
-    {
-        FURI_LOG_E(HTTP_TAG, "Received error: %s", line);
-        fhttp->state = ISSUE;
-        return;
-    }
-    else if (strstr(line, "[PONG]") != NULL)
-    {
-        FURI_LOG_I(HTTP_TAG, "Received PONG response: Wifi Dev Board is still alive.");
-
-        // send command to connect to WiFi
-        if (fhttp->state == INACTIVE)
-        {
-            fhttp->state = IDLE;
-            return;
-        }
-    }
-
-    if (fhttp->state == INACTIVE && strstr(line, "[PONG]") != NULL)
-    {
-        fhttp->state = IDLE;
-    }
-    else if (fhttp->state == INACTIVE && strstr(line, "[PONG]") == NULL)
-    {
-        fhttp->state = INACTIVE;
-    }
-    else
-    {
-        fhttp->state = IDLE;
-    }
-}
-
-/**
- * @brief Process requests and parse JSON data asynchronously
- * @param fhttp The FlipperHTTP context
- * @param http_request The function to send the request
- * @param parse_json The function to parse the JSON
- * @return true if successful, false otherwise
- */
-bool flipper_http_process_response_async(FlipperHTTP *fhttp, bool (*http_request)(void), bool (*parse_json)(void))
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return false;
-    }
-    if (http_request()) // start the async request
-    {
-        furi_timer_start(fhttp->get_timeout_timer, TIMEOUT_DURATION_TICKS);
-        fhttp->state = RECEIVING;
-    }
-    else
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to send request");
-        return false;
-    }
-    while (fhttp->state == RECEIVING && furi_timer_is_running(fhttp->get_timeout_timer) > 0)
-    {
-        // Wait for the request to be received
-        furi_delay_ms(100);
-    }
-    furi_timer_stop(fhttp->get_timeout_timer);
-    if (!parse_json()) // parse the JSON before switching to the view (synchonous)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to parse the JSON...");
-        return false;
-    }
-    return true;
-}
-
-/**
- * @brief Perform a task while displaying a loading screen
- * @param fhttp The FlipperHTTP context
- * @param http_request The function to send the request
- * @param parse_response The function to parse the response
- * @param success_view_id The view ID to switch to on success
- * @param failure_view_id The view ID to switch to on failure
- * @param view_dispatcher The view dispatcher to use
- * @return
- */
-void flipper_http_loading_task(FlipperHTTP *fhttp,
-                               bool (*http_request)(void),
-                               bool (*parse_response)(void),
-                               uint32_t success_view_id,
-                               uint32_t failure_view_id,
-                               ViewDispatcher **view_dispatcher)
-{
-    if (!fhttp)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to get context.");
-        return;
-    }
-    if (fhttp->state == INACTIVE)
-    {
-        view_dispatcher_switch_to_view(*view_dispatcher, failure_view_id);
-        return;
-    }
-    Loading *loading;
-    int32_t loading_view_id = 987654321; // Random ID
-
-    loading = loading_alloc();
-    if (!loading)
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to allocate loading");
-        view_dispatcher_switch_to_view(*view_dispatcher, failure_view_id);
-
-        return;
-    }
-
-    view_dispatcher_add_view(*view_dispatcher, loading_view_id, loading_get_view(loading));
-
-    // Switch to the loading view
-    view_dispatcher_switch_to_view(*view_dispatcher, loading_view_id);
-
-    // Make the request
-    if (!flipper_http_process_response_async(fhttp, http_request, parse_response))
-    {
-        FURI_LOG_E(HTTP_TAG, "Failed to make request");
-        view_dispatcher_switch_to_view(*view_dispatcher, failure_view_id);
-        view_dispatcher_remove_view(*view_dispatcher, loading_view_id);
-        loading_free(loading);
-
-        return;
-    }
-
-    // Switch to the success view
-    view_dispatcher_switch_to_view(*view_dispatcher, success_view_id);
-    view_dispatcher_remove_view(*view_dispatcher, loading_view_id);
-    loading_free(loading); // comment this out if you experience a freeze
-}

+ 0 - 407
flipper_http/flipper_http.h

@@ -1,407 +0,0 @@
-// Description: Flipper HTTP API (For use with Flipper Zero and the FlipperHTTP flash: https://github.com/jblanked/FlipperHTTP)
-// License: MIT
-// Author: JBlanked
-// File: flipper_http.h
-#pragma once
-
-#include <gui/gui.h>
-#include <gui/view.h>
-#include <gui/view_dispatcher.h>
-#include <gui/modules/loading.h>
-#include <furi.h>
-#include <furi_hal.h>
-#include <furi_hal_gpio.h>
-#include <furi_hal_serial.h>
-#include <storage/storage.h>
-
-// STORAGE_EXT_PATH_PREFIX is defined in the Furi SDK as /ext
-
-#define HTTP_TAG "FlipStore"              // change this to your app name
-#define http_tag "flip_store"             // change this to your app id
-#define UART_CH (FuriHalSerialIdUsart)    // UART channel
-#define TIMEOUT_DURATION_TICKS (5 * 1000) // 5 seconds
-#define BAUDRATE (115200)                 // UART baudrate
-#define RX_BUF_SIZE 2048                  // UART RX buffer size
-#define RX_LINE_BUFFER_SIZE 2048          // UART RX line buffer size (increase for large responses)
-#define MAX_FILE_SHOW 12000               // Maximum data from file to show
-#define FILE_BUFFER_SIZE 512              // File buffer size
-
-// Forward declaration for callback
-typedef void (*FlipperHTTP_Callback)(const char *line, void *context);
-
-// State variable to track the UART state
-typedef enum
-{
-    INACTIVE,  // Inactive state
-    IDLE,      // Default state
-    RECEIVING, // Receiving data
-    SENDING,   // Sending data
-    ISSUE,     // Issue with connection
-} SerialState;
-
-// Event Flags for UART Worker Thread
-typedef enum
-{
-    WorkerEvtStop = (1 << 0),
-    WorkerEvtRxDone = (1 << 1),
-} WorkerEvtFlags;
-
-// FlipperHTTP Structure
-typedef struct
-{
-    FuriStreamBuffer *flipper_http_stream;  // Stream buffer for UART communication
-    FuriHalSerialHandle *serial_handle;     // Serial handle for UART communication
-    FuriThread *rx_thread;                  // Worker thread for UART
-    FuriThreadId rx_thread_id;              // Worker thread ID
-    FlipperHTTP_Callback handle_rx_line_cb; // Callback for received lines
-    void *callback_context;                 // Context for the callback
-    SerialState state;                      // State of the UART
-
-    // variable to store the last received data from the UART
-    char *last_response;
-    char file_path[256]; // Path to save the received data
-
-    // Timer-related members
-    FuriTimer *get_timeout_timer; // Timer for HTTP request timeout
-
-    bool started_receiving_get; // Indicates if a GET request has started
-    bool just_started_get;      // Indicates if GET data reception has just started
-
-    bool started_receiving_post; // Indicates if a POST request has started
-    bool just_started_post;      // Indicates if POST data reception has just started
-
-    bool started_receiving_put; // Indicates if a PUT request has started
-    bool just_started_put;      // Indicates if PUT data reception has just started
-
-    bool started_receiving_delete; // Indicates if a DELETE request has started
-    bool just_started_delete;      // Indicates if DELETE data reception has just started
-
-    // Buffer to hold the raw bytes received from the UART
-    uint8_t *received_bytes;
-    size_t received_bytes_len; // Length of the received bytes
-    bool is_bytes_request;     // Flag to indicate if the request is for bytes
-    bool save_bytes;           // Flag to save the received data to a file
-    bool save_received_data;   // Flag to save the received data to a file
-
-    bool just_started_bytes; // Indicates if bytes data reception has just started
-
-    char rx_line_buffer[RX_LINE_BUFFER_SIZE];
-    uint8_t file_buffer[FILE_BUFFER_SIZE];
-    size_t file_buffer_len;
-} FlipperHTTP;
-
-// fhttp.last_response holds the last received data from the UART
-
-// Function to append received data to file
-// make sure to initialize the file path before calling this function
-bool flipper_http_append_to_file(
-    const void *data,
-    size_t data_size,
-    bool start_new_file,
-    char *file_path);
-
-FuriString *flipper_http_load_from_file(char *file_path);
-FuriString *flipper_http_load_from_file_with_limit(char *file_path, size_t limit);
-
-// UART worker thread
-/**
- * @brief      Worker thread to handle UART data asynchronously.
- * @return     0
- * @param      context   The context to pass to the callback.
- * @note       This function will handle received data asynchronously via the callback.
- */
-// UART worker thread
-int32_t flipper_http_worker(void *context);
-
-// Timer callback function
-/**
- * @brief      Callback function for the GET timeout timer.
- * @return     0
- * @param      context   The context to pass to the callback.
- * @note       This function will be called when the GET request times out.
- */
-void get_timeout_timer_callback(void *context);
-
-// UART RX Handler Callback (Interrupt Context)
-/**
- * @brief      A private callback function to handle received data asynchronously.
- * @return     void
- * @param      handle    The UART handle.
- * @param      event     The event type.
- * @param      context   The context to pass to the callback.
- * @note       This function will handle received data asynchronously via the callback.
- */
-void _flipper_http_rx_callback(
-    FuriHalSerialHandle *handle,
-    FuriHalSerialRxEvent event,
-    void *context);
-
-// UART initialization function
-/**
- * @brief      Initialize UART.
- * @return     FlipperHTTP context if the UART was initialized successfully, NULL otherwise.
- * @note       The received data will be handled asynchronously via the callback.
- */
-FlipperHTTP *flipper_http_alloc();
-
-// Deinitialize UART
-/**
- * @brief      Deinitialize UART.
- * @return     void
- * @param fhttp The FlipperHTTP context
- * @note       This function will stop the asynchronous RX, release the serial handle, and free the resources.
- */
-void flipper_http_free(FlipperHTTP *fhttp);
-
-// Function to send data over UART with newline termination
-/**
- * @brief      Send data over UART with newline termination.
- * @return     true if the data was sent successfully, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      data  The data to send over UART.
- * @note       The data will be sent over UART with a newline character appended.
- */
-bool flipper_http_send_data(FlipperHTTP *fhttp, const char *data);
-
-// Function to send a PING request
-/**
- * @brief      Send a PING request to check if the Wifi Dev Board is connected.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- * @note       This is best used to check if the Wifi Dev Board is connected.
- * @note       The state will remain INACTIVE until a PONG is received.
- */
-bool flipper_http_ping(FlipperHTTP *fhttp);
-
-// Function to list available commands
-/**
- * @brief      Send a command to list available commands.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_list_commands(FlipperHTTP *fhttp);
-
-// Function to turn on the LED
-/**
- * @brief      Allow the LED to display while processing.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_led_on(FlipperHTTP *fhttp);
-
-// Function to turn off the LED
-/**
- * @brief      Disable the LED from displaying while processing.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_led_off(FlipperHTTP *fhttp);
-
-// Function to parse JSON data
-/**
- * @brief      Parse JSON data.
- * @return     true if the JSON data was parsed successfully, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      key       The key to parse from the JSON data.
- * @param      json_data The JSON data to parse.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_parse_json(FlipperHTTP *fhttp, const char *key, const char *json_data);
-
-// Function to parse JSON array data
-/**
- * @brief      Parse JSON array data.
- * @return     true if the JSON array data was parsed successfully, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      key       The key to parse from the JSON array data.
- * @param      index     The index to parse from the JSON array data.
- * @param      json_data The JSON array data to parse.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_parse_json_array(FlipperHTTP *fhttp, const char *key, int index, const char *json_data);
-
-// Function to scan for WiFi networks
-/**
- * @brief      Send a command to scan for WiFi networks.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_scan_wifi(FlipperHTTP *fhttp);
-
-// Function to save WiFi settings (returns true if successful)
-/**
- * @brief      Send a command to save WiFi settings.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_save_wifi(FlipperHTTP *fhttp, const char *ssid, const char *password);
-
-// Function to get IP address of WiFi Devboard
-/**
- * @brief      Send a command to get the IP address of the WiFi Devboard
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_ip_address(FlipperHTTP *fhttp);
-
-// Function to get IP address of the connected WiFi network
-/**
- * @brief      Send a command to get the IP address of the connected WiFi network.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_ip_wifi(FlipperHTTP *fhttp);
-
-// Function to disconnect from WiFi (returns true if successful)
-/**
- * @brief      Send a command to disconnect from WiFi.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_disconnect_wifi(FlipperHTTP *fhttp);
-
-// Function to connect to WiFi (returns true if successful)
-/**
- * @brief      Send a command to connect to WiFi.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_connect_wifi(FlipperHTTP *fhttp);
-
-// Function to send a GET request
-/**
- * @brief      Send a GET request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the GET request to.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_get_request(FlipperHTTP *fhttp, const char *url);
-
-// Function to send a GET request with headers
-/**
- * @brief      Send a GET request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the GET request to.
- * @param      headers  The headers to send with the GET request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_get_request_with_headers(FlipperHTTP *fhttp, const char *url, const char *headers);
-
-// Function to send a GET request with headers and return bytes
-/**
- * @brief      Send a GET request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the GET request to.
- * @param      headers  The headers to send with the GET request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_get_request_bytes(FlipperHTTP *fhttp, const char *url, const char *headers);
-
-// Function to send a POST request with headers
-/**
- * @brief      Send a POST request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the POST request to.
- * @param      headers  The headers to send with the POST request.
- * @param      data  The data to send with the POST request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_post_request_with_headers(
-    FlipperHTTP *fhttp,
-    const char *url,
-    const char *headers,
-    const char *payload);
-
-// Function to send a POST request with headers and return bytes
-/**
- * @brief      Send a POST request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the POST request to.
- * @param      headers  The headers to send with the POST request.
- * @param      payload  The data to send with the POST request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_post_request_bytes(FlipperHTTP *fhttp, const char *url, const char *headers, const char *payload);
-
-// Function to send a PUT request with headers
-/**
- * @brief      Send a PUT request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the PUT request to.
- * @param      headers  The headers to send with the PUT request.
- * @param      data  The data to send with the PUT request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_put_request_with_headers(
-    FlipperHTTP *fhttp,
-    const char *url,
-    const char *headers,
-    const char *payload);
-
-// Function to send a DELETE request with headers
-/**
- * @brief      Send a DELETE request to the specified URL.
- * @return     true if the request was successful, false otherwise.
- * @param fhttp The FlipperHTTP context
- * @param      url  The URL to send the DELETE request to.
- * @param      headers  The headers to send with the DELETE request.
- * @param      data  The data to send with the DELETE request.
- * @note       The received data will be handled asynchronously via the callback.
- */
-bool flipper_http_delete_request_with_headers(
-    FlipperHTTP *fhttp,
-    const char *url,
-    const char *headers,
-    const char *payload);
-
-// Function to handle received data asynchronously
-/**
- * @brief      Callback function to handle received data asynchronously.
- * @return     void
- * @param      line     The received line.
- * @param      context  The FlipperHTTP context.
- * @note       The received data will be handled asynchronously via the callback and handles the state of the UART.
- */
-void flipper_http_rx_callback(const char *line, void *context);
-
-/**
- * @brief Process requests and parse JSON data asynchronously
- * @param fhttp The FlipperHTTP context
- * @param http_request The function to send the request
- * @param parse_json The function to parse the JSON
- * @return true if successful, false otherwise
- */
-bool flipper_http_process_response_async(FlipperHTTP *fhttp, bool (*http_request)(void), bool (*parse_json)(void));
-
-/**
- * @brief Perform a task while displaying a loading screen
- * @param fhttp The FlipperHTTP context
- * @param http_request The function to send the request
- * @param parse_response The function to parse the response
- * @param success_view_id The view ID to switch to on success
- * @param failure_view_id The view ID to switch to on failure
- * @param view_dispatcher The view dispatcher to use
- * @return
- */
-void flipper_http_loading_task(FlipperHTTP *fhttp,
-                               bool (*http_request)(void),
-                               bool (*parse_response)(void),
-                               uint32_t success_view_id,
-                               uint32_t failure_view_id,
-                               ViewDispatcher **view_dispatcher);

+ 0 - 378
github/flip_store_github.c

@@ -1,378 +0,0 @@
-#include <github/flip_store_github.h>
-#include <flip_storage/flip_store_storage.h>
-
-// Helper to download a file from Github and save it to the storage
-bool flip_store_download_github_file(
-    FlipperHTTP *fhttp,
-    const char *filename,
-    const char *author,
-    const char *repo,
-    const char *link)
-{
-    if (!fhttp || !filename || !author || !repo || !link)
-    {
-        FURI_LOG_E(TAG, "Invalid arguments.");
-        return false;
-    }
-
-    snprintf(fhttp->file_path, sizeof(fhttp->file_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/%s/%s/%s.txt", author, repo, filename);
-    fhttp->state = IDLE;
-    fhttp->save_received_data = false;
-    fhttp->is_bytes_request = true;
-
-    return flipper_http_get_request_bytes(fhttp, link, "{\"Content-Type\":\"application/octet-stream\"}");
-}
-
-bool flip_store_get_github_contents(FlipperHTTP *fhttp, const char *author, const char *repo)
-{
-    // Create Initial directory
-    Storage *storage = furi_record_open(RECORD_STORAGE);
-
-    char dir[256];
-
-    // create a data directory: /ext/apps_data/flip_store/data
-    snprintf(dir, sizeof(dir), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data");
-    storage_common_mkdir(storage, dir);
-
-    // create a data directory for the author: /ext/apps_data/flip_store/data/author
-    snprintf(dir, sizeof(dir), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data/%s", author);
-    storage_common_mkdir(storage, dir);
-
-    // example path: /ext/apps_data/flip_store/data/author/info.json
-    snprintf(fhttp->file_path, sizeof(fhttp->file_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data/%s/info.json", author);
-
-    // create a data directory for the repo: /ext/apps_data/flip_store/data/author/repo
-    snprintf(dir, sizeof(dir), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data/%s/%s", author, repo);
-    storage_common_mkdir(storage, dir);
-
-    // example path: /ext/apps_data/flip_store/author
-    snprintf(dir, sizeof(dir), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/%s", author);
-    storage_common_mkdir(storage, dir);
-
-    // example path: /ext/apps_data/flip_store/author/repo
-    snprintf(dir, sizeof(dir), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/%s/%s", author, repo);
-    storage_common_mkdir(storage, dir);
-
-    furi_record_close(RECORD_STORAGE);
-
-    // get the contents of the repo
-    char link[256];
-    snprintf(link, sizeof(link), "https://api.github.com/repos/%s/%s/contents", author, repo);
-    fhttp->save_received_data = true;
-    return flipper_http_get_request_with_headers(fhttp, link, "{\"Content-Type\":\"application/json\"}");
-}
-
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-
-// Assuming necessary headers and definitions for FuriString, FURI_LOG, etc., are included.
-
-bool flip_store_parse_github_contents(char *file_path, const char *author, const char *repo)
-{
-    FURI_LOG_I(TAG, "Parsing Github contents from %s - %s.", author, repo);
-    if (!file_path || !author || !repo)
-    {
-        FURI_LOG_E(TAG, "Invalid arguments.");
-        return false;
-    }
-
-    // Load JSON data from file
-    FuriString *git_data = flipper_http_load_from_file(file_path);
-    if (git_data == NULL)
-    {
-        FURI_LOG_E(TAG, "Failed to load received data from file.");
-        return false;
-    }
-
-    // Allocate a new FuriString to hold the entire JSON structure
-    FuriString *git_data_str = furi_string_alloc();
-    if (!git_data_str)
-    {
-        FURI_LOG_E(TAG, "Failed to allocate git_data_str.");
-        furi_string_free(git_data);
-        return false;
-    }
-
-    // Construct the full JSON string
-    furi_string_cat_str(git_data_str, "{\"json_data\":");
-    furi_string_cat(git_data_str, git_data);
-    furi_string_cat_str(git_data_str, "}");
-    furi_string_free(git_data); // Free the original git_data as it's now part of git_data_str
-
-    // Check available memory
-    const size_t additional_bytes = strlen("{\"json_data\":") + 1; // +1 for the closing "}"
-    if (memmgr_get_free_heap() < furi_string_size(git_data_str) + additional_bytes)
-    {
-        FURI_LOG_E(TAG, "Not enough memory to allocate git_data_str.");
-        furi_string_free(git_data_str);
-        return false;
-    }
-
-    int file_count = 0;
-    char dir[512]; // Increased size to accommodate longer paths if necessary
-    FURI_LOG_I(TAG, "Looping through Github files.");
-    FURI_LOG_I(TAG, "Available memory: %d bytes", memmgr_get_free_heap());
-
-    // Get the C-string and its length for processing
-    char *data = (char *)furi_string_get_cstr(git_data_str);
-    size_t data_len = furi_string_size(git_data_str);
-
-    size_t pos = 0; // Current position in the data string
-    // Locate the start of the JSON array
-    char *array_start = strchr(data, '[');
-    if (!array_start)
-    {
-        FURI_LOG_E(TAG, "Invalid JSON format: '[' not found.");
-        furi_string_free(git_data_str);
-        return false;
-    }
-    pos = array_start - data; // Update position to the start of the array
-    size_t brace_count = 0;
-    size_t obj_start = 0;
-    bool in_string = false; // To handle braces inside strings
-
-    while (pos < data_len && file_count < MAX_GITHUB_FILES)
-    {
-        char current = data[pos];
-
-        // Toggle in_string flag if a quote is found (handling escaped quotes)
-        if (current == '"' && (pos == 0 || data[pos - 1] != '\\'))
-        {
-            in_string = !in_string;
-        }
-
-        if (!in_string)
-        {
-            if (current == '{')
-            {
-                if (brace_count == 0)
-                {
-                    obj_start = pos; // Potential start of a JSON object
-                }
-                brace_count++;
-            }
-            else if (current == '}')
-            {
-                brace_count--;
-                if (brace_count == 0)
-                {
-                    size_t obj_end = pos;
-                    size_t obj_length = obj_end - obj_start + 1;
-                    // Extract the JSON object substring
-                    char *obj_str = malloc(obj_length + 1);
-                    if (!obj_str)
-                    {
-                        FURI_LOG_E(TAG, "Memory allocation failed for obj_str.");
-                        break;
-                    }
-                    strncpy(obj_str, data + obj_start, obj_length);
-                    obj_str[obj_length] = '\0'; // Null-terminate
-
-                    FuriString *json_data_array = furi_string_alloc();
-                    furi_string_set(json_data_array, obj_str); // Set the string to the allocated memory
-                    free(obj_str);                             // Free the temporary C-string
-
-                    if (!json_data_array)
-                    {
-                        FURI_LOG_E(TAG, "Failed to initialize json_data_array.");
-                        break;
-                    }
-
-                    FURI_LOG_I(TAG, "Loaded json data array value %d. Available memory: %d bytes", file_count, memmgr_get_free_heap());
-
-                    // Extract "type" field
-                    FuriString *type = get_json_value_furi("type", json_data_array);
-                    if (!type)
-                    {
-                        FURI_LOG_E(TAG, "Failed to get type.");
-                        furi_string_free(json_data_array);
-                        break;
-                    }
-
-                    // Skip non-file types (e.g., directories)
-                    if (strcmp(furi_string_get_cstr(type), "file") != 0)
-                    {
-                        furi_string_free(type);
-                        furi_string_free(json_data_array);
-                        pos = obj_end + 1; // Move past this object
-                        continue;
-                    }
-                    furi_string_free(type);
-
-                    // Extract "download_url" and "name"
-                    FuriString *download_url = get_json_value_furi("download_url", json_data_array);
-                    if (!download_url)
-                    {
-                        FURI_LOG_E(TAG, "Failed to get download_url.");
-                        furi_string_free(json_data_array);
-                        break;
-                    }
-
-                    FuriString *name = get_json_value_furi("name", json_data_array);
-                    if (!name)
-                    {
-                        FURI_LOG_E(TAG, "Failed to get name.");
-                        furi_string_free(json_data_array);
-                        furi_string_free(download_url);
-                        break;
-                    }
-
-                    furi_string_free(json_data_array);
-                    FURI_LOG_I(TAG, "Received name and download_url. Available memory: %d bytes", memmgr_get_free_heap());
-
-                    // Create JSON to save
-                    FuriString *json = furi_string_alloc();
-                    if (!json)
-                    {
-                        FURI_LOG_E(TAG, "Failed to allocate json.");
-                        furi_string_free(download_url);
-                        furi_string_free(name);
-                        break;
-                    }
-
-                    furi_string_cat_str(json, "{\"name\":\"");
-                    furi_string_cat(json, name);
-                    furi_string_cat_str(json, "\",\"link\":\"");
-                    furi_string_cat(json, download_url);
-                    furi_string_cat_str(json, "\"}");
-
-                    FURI_LOG_I(TAG, "Created json. Available memory: %d bytes", memmgr_get_free_heap());
-
-                    // Save the JSON to the data folder: /ext/apps_data/flip_store/data/author/repo/fileX.json
-                    snprintf(dir, sizeof(dir), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data/%s/%s/file%d.json", author, repo, file_count);
-                    if (!save_char_with_path(dir, furi_string_get_cstr(json)))
-                    {
-                        FURI_LOG_E(TAG, "Failed to save json.");
-                    }
-
-                    FURI_LOG_I(TAG, "Saved file %s.", furi_string_get_cstr(name));
-
-                    // Free allocated resources
-                    furi_string_free(name);
-                    furi_string_free(download_url);
-                    furi_string_free(json);
-
-                    file_count++;
-
-                    // This can be expensive for large strings; consider memory constraints
-                    size_t remaining_length = data_len - (obj_end + 1);
-                    memmove(data + obj_start, data + obj_end + 1, remaining_length + 1); // +1 to include null terminator
-                    data_len -= (obj_end + 1 - obj_start);
-                    pos = obj_start; // Reset position to the start of the modified string
-                    continue;
-                }
-            }
-        }
-
-        pos++;
-    }
-
-    furi_string_free(git_data_str);
-
-    // Save file count
-    char file_count_str[16];
-    snprintf(file_count_str, sizeof(file_count_str), "%d", file_count);
-    char file_count_dir[512]; // Increased size for longer paths
-    snprintf(file_count_dir, sizeof(file_count_dir), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data/%s/file_count.txt", author);
-
-    FURI_LOG_I(TAG, "Successfully parsed %d files.", file_count);
-    return save_char_with_path(file_count_dir, file_count_str);
-}
-
-bool flip_store_install_all_github_files(FlipperHTTP *fhttp, const char *author, const char *repo)
-{
-    FURI_LOG_I(TAG, "Installing all Github files.");
-    if (!fhttp || !author || !repo)
-    {
-        FURI_LOG_E(TAG, "Invalid arguments.");
-        return false;
-    }
-    fhttp->state = RECEIVING;
-    // get the file count
-    char file_count_dir[256]; // /ext/apps_data/flip_store/data/author/file_count.txt
-    snprintf(file_count_dir, sizeof(file_count_dir), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data/%s/file_count.txt", author);
-    FuriString *file_count = flipper_http_load_from_file(file_count_dir);
-    if (file_count == NULL)
-    {
-        FURI_LOG_E(TAG, "Failed to load file count.");
-        return false;
-    }
-    int count = atoi(furi_string_get_cstr(file_count));
-    furi_string_free(file_count);
-
-    // install all files
-    char file_dir[256]; // /ext/apps_data/flip_store/data/author/repo/file.json
-    FURI_LOG_I(TAG, "Installing %d files.", count);
-    for (int i = 0; i < count; i++)
-    {
-        snprintf(file_dir, sizeof(file_dir), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/data/%s/%s/file%d.json", author, repo, i);
-        FURI_LOG_I(TAG, "Loading file %s. Available memory: %d bytes", file_dir, memmgr_get_free_heap());
-        FuriString *file = flipper_http_load_from_file_with_limit(file_dir, 512);
-        if (!file)
-        {
-            FURI_LOG_E(TAG, "Failed to load file.");
-            return false;
-        }
-        FURI_LOG_I(TAG, "Loaded file %s.", file_dir);
-        FuriString *name = get_json_value_furi("name", file);
-        if (!name)
-        {
-            FURI_LOG_E(TAG, "Failed to get name.");
-            furi_string_free(file);
-            return false;
-        }
-        FuriString *link = get_json_value_furi("link", file);
-        if (!link)
-        {
-            FURI_LOG_E(TAG, "Failed to get link.");
-            furi_string_free(file);
-            furi_string_free(name);
-            return false;
-        }
-        furi_string_free(file);
-
-        bool fetch_file()
-        {
-            return flip_store_download_github_file(fhttp, furi_string_get_cstr(name), author, repo, furi_string_get_cstr(link));
-        }
-
-        bool parse()
-        {
-            // remove .txt from the filename
-            char current_file_path[512];
-            char new_file_path[512];
-            snprintf(current_file_path, sizeof(current_file_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/%s/%s/%s.txt", author, repo, furi_string_get_cstr(name));
-            snprintf(new_file_path, sizeof(new_file_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/%s/%s/%s", author, repo, furi_string_get_cstr(name));
-            Storage *storage = furi_record_open(RECORD_STORAGE);
-            if (!storage_file_exists(storage, current_file_path))
-            {
-                FURI_LOG_E(TAG, "Failed to download file.");
-                furi_record_close(RECORD_STORAGE);
-                return false;
-            }
-            if (storage_common_rename(storage, current_file_path, new_file_path) != FSE_OK)
-            {
-                FURI_LOG_E(TAG, "Failed to rename file.");
-                furi_record_close(RECORD_STORAGE);
-                return false;
-            }
-            furi_record_close(RECORD_STORAGE);
-            return true;
-        }
-        // download the file and wait until it is downloaded
-        FURI_LOG_I(TAG, "Downloading file %s", furi_string_get_cstr(name));
-        if (!flipper_http_process_response_async(fhttp, fetch_file, parse))
-        {
-            FURI_LOG_E(TAG, "Failed to download file.");
-            furi_string_free(name);
-            furi_string_free(link);
-            return false;
-        }
-        FURI_LOG_I(TAG, "Downloaded file %s", furi_string_get_cstr(name));
-        furi_string_free(name);
-        furi_string_free(link);
-    }
-    fhttp->state = IDLE;
-    return true;
-}

+ 0 - 26
github/flip_store_github.h

@@ -1,26 +0,0 @@
-#pragma once
-#include <flip_store.h>
-
-/*
-I did try downloading a zip file from Github but a few issues
-- unsure how to unzip the file
-- either Github redirected us to a loading page, or their was no response on if using an IoT device
-- any contributions to this would be appreciated
-*/
-
-// Helper to download a file from Github and save it to the storage
-bool flip_store_download_github_file(
-    FlipperHTTP *fhttp,
-    const char *filename,
-    const char *author,
-    const char *repo,
-    const char *link);
-
-// Helper to get the contents of a Github repo (from https://api.github.com/repos/author/repo/contents)
-bool flip_store_get_github_contents(FlipperHTTP *fhttp, const char *author, const char *repo);
-
-// Helper to parse the contents of a Github repo (takes parts of the data and saves it for easy access later)
-bool flip_store_parse_github_contents(char *file_path, const char *author, const char *repo);
-
-// Helper to install all files from the parsed Github repo contents in flip_store_parse_github_contents
-bool flip_store_install_all_github_files(FlipperHTTP *fhttp, const char *author, const char *repo);

+ 0 - 803
jsmn/jsmn.c

@@ -1,803 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2010 Serge Zaitsev
- *
- * [License text continues...]
- */
-
-#include <jsmn/jsmn.h>
-
-/**
- * Allocates a fresh unused token from the token pool.
- */
-static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens,
-                                   const size_t num_tokens)
-{
-    jsmntok_t *tok;
-
-    if (parser->toknext >= num_tokens)
-    {
-        return NULL;
-    }
-    tok = &tokens[parser->toknext++];
-    tok->start = tok->end = -1;
-    tok->size = 0;
-#ifdef JSMN_PARENT_LINKS
-    tok->parent = -1;
-#endif
-    return tok;
-}
-
-/**
- * Fills token type and boundaries.
- */
-static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type,
-                            const int start, const int end)
-{
-    token->type = type;
-    token->start = start;
-    token->end = end;
-    token->size = 0;
-}
-
-/**
- * Fills next available token with JSON primitive.
- */
-static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
-                                const size_t len, jsmntok_t *tokens,
-                                const size_t num_tokens)
-{
-    jsmntok_t *token;
-    int start;
-
-    start = parser->pos;
-
-    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
-    {
-        switch (js[parser->pos])
-        {
-#ifndef JSMN_STRICT
-        /* In strict mode primitive must be followed by "," or "}" or "]" */
-        case ':':
-#endif
-        case '\t':
-        case '\r':
-        case '\n':
-        case ' ':
-        case ',':
-        case ']':
-        case '}':
-            goto found;
-        default:
-            /* to quiet a warning from gcc*/
-            break;
-        }
-        if (js[parser->pos] < 32 || js[parser->pos] >= 127)
-        {
-            parser->pos = start;
-            return JSMN_ERROR_INVAL;
-        }
-    }
-#ifdef JSMN_STRICT
-    /* In strict mode primitive must be followed by a comma/object/array */
-    parser->pos = start;
-    return JSMN_ERROR_PART;
-#endif
-
-found:
-    if (tokens == NULL)
-    {
-        parser->pos--;
-        return 0;
-    }
-    token = jsmn_alloc_token(parser, tokens, num_tokens);
-    if (token == NULL)
-    {
-        parser->pos = start;
-        return JSMN_ERROR_NOMEM;
-    }
-    jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
-#ifdef JSMN_PARENT_LINKS
-    token->parent = parser->toksuper;
-#endif
-    parser->pos--;
-    return 0;
-}
-
-/**
- * Fills next token with JSON string.
- */
-static int jsmn_parse_string(jsmn_parser *parser, const char *js,
-                             const size_t len, jsmntok_t *tokens,
-                             const size_t num_tokens)
-{
-    jsmntok_t *token;
-
-    int start = parser->pos;
-
-    /* Skip starting quote */
-    parser->pos++;
-
-    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
-    {
-        char c = js[parser->pos];
-
-        /* Quote: end of string */
-        if (c == '\"')
-        {
-            if (tokens == NULL)
-            {
-                return 0;
-            }
-            token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if (token == NULL)
-            {
-                parser->pos = start;
-                return JSMN_ERROR_NOMEM;
-            }
-            jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos);
-#ifdef JSMN_PARENT_LINKS
-            token->parent = parser->toksuper;
-#endif
-            return 0;
-        }
-
-        /* Backslash: Quoted symbol expected */
-        if (c == '\\' && parser->pos + 1 < len)
-        {
-            int i;
-            parser->pos++;
-            switch (js[parser->pos])
-            {
-            /* Allowed escaped symbols */
-            case '\"':
-            case '/':
-            case '\\':
-            case 'b':
-            case 'f':
-            case 'r':
-            case 'n':
-            case 't':
-                break;
-            /* Allows escaped symbol \uXXXX */
-            case 'u':
-                parser->pos++;
-                for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++)
-                {
-                    /* If it isn't a hex character we have an error */
-                    if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
-                          (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
-                          (js[parser->pos] >= 97 && js[parser->pos] <= 102)))
-                    { /* a-f */
-                        parser->pos = start;
-                        return JSMN_ERROR_INVAL;
-                    }
-                    parser->pos++;
-                }
-                parser->pos--;
-                break;
-            /* Unexpected symbol */
-            default:
-                parser->pos = start;
-                return JSMN_ERROR_INVAL;
-            }
-        }
-    }
-    parser->pos = start;
-    return JSMN_ERROR_PART;
-}
-
-/**
- * Create JSON parser over an array of tokens
- */
-void jsmn_init(jsmn_parser *parser)
-{
-    parser->pos = 0;
-    parser->toknext = 0;
-    parser->toksuper = -1;
-}
-
-/**
- * Parse JSON string and fill tokens.
- */
-int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
-               jsmntok_t *tokens, const unsigned int num_tokens)
-{
-    int r;
-    int i;
-    jsmntok_t *token;
-    int count = parser->toknext;
-
-    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
-    {
-        char c;
-        jsmntype_t type;
-
-        c = js[parser->pos];
-        switch (c)
-        {
-        case '{':
-        case '[':
-            count++;
-            if (tokens == NULL)
-            {
-                break;
-            }
-            token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if (token == NULL)
-            {
-                return JSMN_ERROR_NOMEM;
-            }
-            if (parser->toksuper != -1)
-            {
-                jsmntok_t *t = &tokens[parser->toksuper];
-#ifdef JSMN_STRICT
-                /* In strict mode an object or array can't become a key */
-                if (t->type == JSMN_OBJECT)
-                {
-                    return JSMN_ERROR_INVAL;
-                }
-#endif
-                t->size++;
-#ifdef JSMN_PARENT_LINKS
-                token->parent = parser->toksuper;
-#endif
-            }
-            token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
-            token->start = parser->pos;
-            parser->toksuper = parser->toknext - 1;
-            break;
-        case '}':
-        case ']':
-            if (tokens == NULL)
-            {
-                break;
-            }
-            type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
-#ifdef JSMN_PARENT_LINKS
-            if (parser->toknext < 1)
-            {
-                return JSMN_ERROR_INVAL;
-            }
-            token = &tokens[parser->toknext - 1];
-            for (;;)
-            {
-                if (token->start != -1 && token->end == -1)
-                {
-                    if (token->type != type)
-                    {
-                        return JSMN_ERROR_INVAL;
-                    }
-                    token->end = parser->pos + 1;
-                    parser->toksuper = token->parent;
-                    break;
-                }
-                if (token->parent == -1)
-                {
-                    if (token->type != type || parser->toksuper == -1)
-                    {
-                        return JSMN_ERROR_INVAL;
-                    }
-                    break;
-                }
-                token = &tokens[token->parent];
-            }
-#else
-            for (i = parser->toknext - 1; i >= 0; i--)
-            {
-                token = &tokens[i];
-                if (token->start != -1 && token->end == -1)
-                {
-                    if (token->type != type)
-                    {
-                        return JSMN_ERROR_INVAL;
-                    }
-                    parser->toksuper = -1;
-                    token->end = parser->pos + 1;
-                    break;
-                }
-            }
-            /* Error if unmatched closing bracket */
-            if (i == -1)
-            {
-                return JSMN_ERROR_INVAL;
-            }
-            for (; i >= 0; i--)
-            {
-                token = &tokens[i];
-                if (token->start != -1 && token->end == -1)
-                {
-                    parser->toksuper = i;
-                    break;
-                }
-            }
-#endif
-            break;
-        case '\"':
-            r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
-            if (r < 0)
-            {
-                return r;
-            }
-            count++;
-            if (parser->toksuper != -1 && tokens != NULL)
-            {
-                tokens[parser->toksuper].size++;
-            }
-            break;
-        case '\t':
-        case '\r':
-        case '\n':
-        case ' ':
-            break;
-        case ':':
-            parser->toksuper = parser->toknext - 1;
-            break;
-        case ',':
-            if (tokens != NULL && parser->toksuper != -1 &&
-                tokens[parser->toksuper].type != JSMN_ARRAY &&
-                tokens[parser->toksuper].type != JSMN_OBJECT)
-            {
-#ifdef JSMN_PARENT_LINKS
-                parser->toksuper = tokens[parser->toksuper].parent;
-#else
-                for (i = parser->toknext - 1; i >= 0; i--)
-                {
-                    if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT)
-                    {
-                        if (tokens[i].start != -1 && tokens[i].end == -1)
-                        {
-                            parser->toksuper = i;
-                            break;
-                        }
-                    }
-                }
-#endif
-            }
-            break;
-#ifdef JSMN_STRICT
-        /* In strict mode primitives are: numbers and booleans */
-        case '-':
-        case '0':
-        case '1':
-        case '2':
-        case '3':
-        case '4':
-        case '5':
-        case '6':
-        case '7':
-        case '8':
-        case '9':
-        case 't':
-        case 'f':
-        case 'n':
-            /* And they must not be keys of the object */
-            if (tokens != NULL && parser->toksuper != -1)
-            {
-                const jsmntok_t *t = &tokens[parser->toksuper];
-                if (t->type == JSMN_OBJECT ||
-                    (t->type == JSMN_STRING && t->size != 0))
-                {
-                    return JSMN_ERROR_INVAL;
-                }
-            }
-#else
-        /* In non-strict mode every unquoted value is a primitive */
-        default:
-#endif
-            r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
-            if (r < 0)
-            {
-                return r;
-            }
-            count++;
-            if (parser->toksuper != -1 && tokens != NULL)
-            {
-                tokens[parser->toksuper].size++;
-            }
-            break;
-
-#ifdef JSMN_STRICT
-        /* Unexpected char in strict mode */
-        default:
-            return JSMN_ERROR_INVAL;
-#endif
-        }
-    }
-
-    if (tokens != NULL)
-    {
-        for (i = parser->toknext - 1; i >= 0; i--)
-        {
-            /* Unmatched opened object or array */
-            if (tokens[i].start != -1 && tokens[i].end == -1)
-            {
-                return JSMN_ERROR_PART;
-            }
-        }
-    }
-
-    return count;
-}
-
-// Helper function to create a JSON object
-char *get_json(const char *key, const char *value)
-{
-    int length = strlen(key) + strlen(value) + 8;         // Calculate required length
-    char *result = (char *)malloc(length * sizeof(char)); // Allocate memory
-    if (result == NULL)
-    {
-        return NULL; // Handle memory allocation failure
-    }
-    snprintf(result, length, "{\"%s\":\"%s\"}", key, value);
-    return result; // Caller is responsible for freeing this memory
-}
-
-// Helper function to compare JSON keys
-int jsoneq(const char *json, jsmntok_t *tok, const char *s)
-{
-    if (tok->type == JSMN_STRING && (int)strlen(s) == tok->end - tok->start &&
-        strncmp(json + tok->start, s, tok->end - tok->start) == 0)
-    {
-        return 0;
-    }
-    return -1;
-}
-
-// Return the value of the key in the JSON data
-char *get_json_value(char *key, const char *json_data)
-{
-    // Parse the JSON feed
-    if (json_data != NULL)
-    {
-        jsmn_parser parser;
-        jsmn_init(&parser);
-        uint32_t max_tokens = json_token_count(json_data);
-        if (!jsmn_memory_check(max_tokens))
-        {
-            FURI_LOG_E("JSMM.H", "Insufficient memory for JSON tokens.");
-            return NULL;
-        }
-        // Allocate tokens array on the heap
-        jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens);
-        if (tokens == NULL)
-        {
-            FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
-            return NULL;
-        }
-
-        int ret = jsmn_parse(&parser, json_data, strlen(json_data), tokens, max_tokens);
-        if (ret < 0)
-        {
-            // Handle parsing errors
-            FURI_LOG_E("JSMM.H", "Failed to parse JSON: %d", ret);
-            free(tokens);
-            return NULL;
-        }
-
-        // Ensure that the root element is an object
-        if (ret < 1 || tokens[0].type != JSMN_OBJECT)
-        {
-            FURI_LOG_E("JSMM.H", "Root element is not an object.");
-            free(tokens);
-            return NULL;
-        }
-
-        // Loop through the tokens to find the key
-        for (int i = 1; i < ret; i++)
-        {
-            if (jsoneq(json_data, &tokens[i], key) == 0)
-            {
-                // We found the key. Now, return the associated value.
-                int length = tokens[i + 1].end - tokens[i + 1].start;
-                char *value = malloc(length + 1);
-                if (value == NULL)
-                {
-                    FURI_LOG_E("JSMM.H", "Failed to allocate memory for value.");
-                    free(tokens);
-                    return NULL;
-                }
-                strncpy(value, json_data + tokens[i + 1].start, length);
-                value[length] = '\0'; // Null-terminate the string
-
-                free(tokens); // Free the token array
-                return value; // Return the extracted value
-            }
-        }
-
-        // Free the token array if key was not found
-        free(tokens);
-    }
-    else
-    {
-        FURI_LOG_E("JSMM.H", "JSON data is NULL");
-    }
-    char warning[128];
-    snprintf(warning, sizeof(warning), "Failed to find the key \"%s\" in the JSON.", key);
-    FURI_LOG_E("JSMM.H", warning);
-    return NULL; // Return NULL if something goes wrong
-}
-
-// Helper function to skip a token and all its descendants.
-// Returns the index of the next token after skipping this one.
-// On error or out of bounds, returns -1.
-static int skip_token(const jsmntok_t *tokens, int start, int total)
-{
-    if (start < 0 || start >= total)
-        return -1;
-
-    int i = start;
-    if (tokens[i].type == JSMN_OBJECT)
-    {
-        // For an object: size is number of key-value pairs
-        int pairs = tokens[i].size;
-        i++; // move to first key-value pair
-        for (int p = 0; p < pairs; p++)
-        {
-            // skip key (primitive/string)
-            i++;
-            if (i >= total)
-                return -1;
-            // skip value (which could be object/array and must be skipped recursively)
-            i = skip_token(tokens, i, total);
-            if (i == -1)
-                return -1;
-        }
-        return i; // i is now just past the object
-    }
-    else if (tokens[i].type == JSMN_ARRAY)
-    {
-        // For an array: size is number of elements
-        int elems = tokens[i].size;
-        i++; // move to first element
-        for (int e = 0; e < elems; e++)
-        {
-            i = skip_token(tokens, i, total);
-            if (i == -1)
-                return -1;
-        }
-        return i; // i is now just past the array
-    }
-    else
-    {
-        // Primitive or string token, just skip it
-        return i + 1;
-    }
-}
-
-// Revised get_json_array_value
-char *get_json_array_value(char *key, uint32_t index, const char *json_data)
-{
-    // Always extract the full array each time from the original json_data
-    char *array_str = get_json_value(key, json_data);
-    if (array_str == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to get array for key: %s", key);
-        return NULL;
-    }
-    uint32_t max_tokens = json_token_count(array_str);
-    if (!jsmn_memory_check(max_tokens))
-    {
-        FURI_LOG_E("JSMM.H", "Insufficient memory for JSON tokens.");
-        free(array_str);
-        return NULL;
-    }
-
-    jsmn_parser parser;
-    jsmn_init(&parser);
-    jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens);
-    if (tokens == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
-        free(array_str);
-        return NULL;
-    }
-
-    int ret = jsmn_parse(&parser, array_str, strlen(array_str), tokens, max_tokens);
-    if (ret < 0)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
-        free(tokens);
-        free(array_str);
-        return NULL;
-    }
-
-    if (ret < 1 || tokens[0].type != JSMN_ARRAY)
-    {
-        FURI_LOG_E("JSMM.H", "Value for key '%s' is not an array.", key);
-        free(tokens);
-        free(array_str);
-        return NULL;
-    }
-
-    if (index >= (uint32_t)tokens[0].size)
-    {
-        // FURI_LOG_E("JSMM.H", "Index %lu out of bounds for array with size %u.", index, tokens[0].size);
-        free(tokens);
-        free(array_str);
-        return NULL;
-    }
-
-    // Find the index-th element: start from token[1], which is the first element
-    int elem_token = 1;
-    for (uint32_t i = 0; i < index; i++)
-    {
-        elem_token = skip_token(tokens, elem_token, ret);
-        if (elem_token == -1 || elem_token >= ret)
-        {
-            FURI_LOG_E("JSMM.H", "Error skipping tokens to reach element %lu.", i);
-            free(tokens);
-            free(array_str);
-            return NULL;
-        }
-    }
-
-    // Now elem_token should point to the token of the requested element
-    jsmntok_t element = tokens[elem_token];
-    int length = element.end - element.start;
-    char *value = malloc(length + 1);
-    if (!value)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to allocate memory for array element.");
-        free(tokens);
-        free(array_str);
-        return NULL;
-    }
-
-    strncpy(value, array_str + element.start, length);
-    value[length] = '\0';
-
-    free(tokens);
-    free(array_str);
-
-    return value;
-}
-
-// Revised get_json_array_values function with correct token skipping
-char **get_json_array_values(char *key, char *json_data, int *num_values)
-{
-    // Retrieve the array string for the given key
-    char *array_str = get_json_value(key, json_data);
-    if (array_str == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to get array for key: %s", key);
-        return NULL;
-    }
-    uint32_t max_tokens = json_token_count(array_str);
-    if (!jsmn_memory_check(max_tokens))
-    {
-        FURI_LOG_E("JSMM.H", "Insufficient memory for JSON tokens.");
-        free(array_str);
-        return NULL;
-    }
-    // Initialize the JSON parser
-    jsmn_parser parser;
-    jsmn_init(&parser);
-
-    // Allocate memory for JSON tokens
-    jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens); // Allocate on the heap
-    if (tokens == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
-        free(array_str);
-        return NULL;
-    }
-
-    // Parse the JSON array
-    int ret = jsmn_parse(&parser, array_str, strlen(array_str), tokens, max_tokens);
-    if (ret < 0)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
-        free(tokens);
-        free(array_str);
-        return NULL;
-    }
-
-    // Ensure the root element is an array
-    if (tokens[0].type != JSMN_ARRAY)
-    {
-        FURI_LOG_E("JSMM.H", "Value for key '%s' is not an array.", key);
-        free(tokens);
-        free(array_str);
-        return NULL;
-    }
-
-    // Allocate memory for the array of values (maximum possible)
-    int array_size = tokens[0].size;
-    char **values = malloc(array_size * sizeof(char *));
-    if (values == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to allocate memory for array of values.");
-        free(tokens);
-        free(array_str);
-        return NULL;
-    }
-
-    int actual_num_values = 0;
-
-    // Traverse the array and extract all object values
-    int current_token = 1; // Start after the array token
-    for (int i = 0; i < array_size; i++)
-    {
-        if (current_token >= ret)
-        {
-            FURI_LOG_E("JSMM.H", "Unexpected end of tokens while traversing array.");
-            break;
-        }
-
-        jsmntok_t element = tokens[current_token];
-
-        if (element.type != JSMN_OBJECT)
-        {
-            FURI_LOG_E("JSMM.H", "Array element %d is not an object, skipping.", i);
-            // Skip this element
-            current_token += 1;
-            continue;
-        }
-
-        int length = element.end - element.start;
-
-        // Allocate a new string for the value and copy the data
-        char *value = malloc(length + 1);
-        if (value == NULL)
-        {
-            FURI_LOG_E("JSMM.H", "Failed to allocate memory for array element.");
-            for (int j = 0; j < actual_num_values; j++)
-            {
-                free(values[j]);
-            }
-            free(values);
-            free(tokens);
-            free(array_str);
-            return NULL;
-        }
-
-        strncpy(value, array_str + element.start, length);
-        value[length] = '\0'; // Null-terminate the string
-
-        values[actual_num_values] = value;
-        actual_num_values++;
-
-        // Skip all tokens related to this object to avoid misparsing
-        current_token += 1 + (2 * element.size); // Each key-value pair consumes two tokens
-    }
-
-    *num_values = actual_num_values;
-
-    // Reallocate the values array to actual_num_values if necessary
-    if (actual_num_values < array_size)
-    {
-        char **reduced_values = realloc(values, actual_num_values * sizeof(char *));
-        if (reduced_values != NULL)
-        {
-            values = reduced_values;
-        }
-
-        // Free the remaining values
-        for (int i = actual_num_values; i < array_size; i++)
-        {
-            free(values[i]);
-        }
-    }
-
-    // Clean up
-    free(tokens);
-    free(array_str);
-    return values;
-}
-
-int json_token_count(const char *json)
-{
-    if (json == NULL)
-    {
-        return JSMN_ERROR_INVAL;
-    }
-
-    jsmn_parser parser;
-    jsmn_init(&parser);
-
-    // Pass NULL for tokens and 0 for num_tokens to get the token count only
-    int ret = jsmn_parse(&parser, json, strlen(json), NULL, 0);
-    return ret; // If ret >= 0, it represents the number of tokens needed.
-}

+ 0 - 74
jsmn/jsmn.h

@@ -1,74 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2010 Serge Zaitsev
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * [License text continues...]
- */
-
-#ifndef JSMN_H
-#define JSMN_H
-
-#include <stddef.h>
-#include <jsmn/jsmn_h.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#ifdef JSMN_STATIC
-#define JSMN_API static
-#else
-#define JSMN_API extern
-#endif
-    /**
-     * Create JSON parser over an array of tokens
-     */
-    JSMN_API void jsmn_init(jsmn_parser *parser);
-
-    /**
-     * Run JSON parser. It parses a JSON data string into and array of tokens, each
-     * describing a single JSON object.
-     */
-    JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
-                            jsmntok_t *tokens, const unsigned int num_tokens);
-
-#ifndef JSMN_HEADER
-/* Implementation has been moved to jsmn.c */
-#endif /* JSMN_HEADER */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* JSMN_H */
-
-/* Custom Helper Functions */
-#ifndef JB_JSMN_EDIT
-#define JB_JSMN_EDIT
-/* Added in by JBlanked on 2024-10-16 for use in Flipper Zero SDK*/
-
-// Helper function to create a JSON object
-char *get_json(const char *key, const char *value);
-// Helper function to compare JSON keys
-int jsoneq(const char *json, jsmntok_t *tok, const char *s);
-
-// Return the value of the key in the JSON data
-char *get_json_value(char *key, const char *json_data);
-
-// Revised get_json_array_value function
-char *get_json_array_value(char *key, uint32_t index, const char *json_data);
-
-// Revised get_json_array_values function with correct token skipping
-char **get_json_array_values(char *key, char *json_data, int *num_values);
-
-int json_token_count(const char *json);
-#endif /* JB_JSMN_EDIT */

+ 0 - 736
jsmn/jsmn_furi.c

@@ -1,736 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2010 Serge Zaitsev
- *
- * [License text continues...]
- */
-
-#include <jsmn/jsmn_furi.h>
-
-// Forward declarations of helper functions
-static int jsoneq_furi(const FuriString *json, jsmntok_t *tok, const FuriString *s);
-static int skip_token(const jsmntok_t *tokens, int start, int total);
-
-/**
- * Allocates a fresh unused token from the token pool.
- */
-static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens,
-                                   const size_t num_tokens)
-{
-    if (parser->toknext >= num_tokens)
-    {
-        return NULL;
-    }
-    jsmntok_t *tok = &tokens[parser->toknext++];
-    tok->start = tok->end = -1;
-    tok->size = 0;
-#ifdef JSMN_PARENT_LINKS
-    tok->parent = -1;
-#endif
-    return tok;
-}
-
-/**
- * Fills token type and boundaries.
- */
-static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type,
-                            const int start, const int end)
-{
-    token->type = type;
-    token->start = start;
-    token->end = end;
-    token->size = 0;
-}
-
-/**
- * Fills next available token with JSON primitive.
- * Now uses FuriString to access characters.
- */
-static int jsmn_parse_primitive(jsmn_parser *parser, const FuriString *js,
-                                jsmntok_t *tokens, const size_t num_tokens)
-{
-    size_t len = furi_string_size(js);
-    int start = parser->pos;
-
-    for (; parser->pos < len; parser->pos++)
-    {
-        char c = furi_string_get_char(js, parser->pos);
-        switch (c)
-        {
-#ifndef JSMN_STRICT
-        case ':':
-#endif
-        case '\t':
-        case '\r':
-        case '\n':
-        case ' ':
-        case ',':
-        case ']':
-        case '}':
-            goto found;
-        default:
-            break;
-        }
-        if (c < 32 || c >= 127)
-        {
-            parser->pos = start;
-            return JSMN_ERROR_INVAL;
-        }
-    }
-
-#ifdef JSMN_STRICT
-    // In strict mode primitive must be followed by a comma/object/array
-    parser->pos = start;
-    return JSMN_ERROR_PART;
-#endif
-
-found:
-    if (tokens == NULL)
-    {
-        parser->pos--;
-        return 0;
-    }
-    jsmntok_t *token = jsmn_alloc_token(parser, tokens, num_tokens);
-    if (token == NULL)
-    {
-        parser->pos = start;
-        return JSMN_ERROR_NOMEM;
-    }
-    jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
-#ifdef JSMN_PARENT_LINKS
-    token->parent = parser->toksuper;
-#endif
-    parser->pos--;
-    return 0;
-}
-
-/**
- * Fills next token with JSON string.
- * Now uses FuriString to access characters.
- */
-static int jsmn_parse_string(jsmn_parser *parser, const FuriString *js,
-                             jsmntok_t *tokens, const size_t num_tokens)
-{
-    size_t len = furi_string_size(js);
-    int start = parser->pos;
-    parser->pos++;
-
-    for (; parser->pos < len; parser->pos++)
-    {
-        char c = furi_string_get_char(js, parser->pos);
-        if (c == '\"')
-        {
-            if (tokens == NULL)
-            {
-                return 0;
-            }
-            jsmntok_t *token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if (token == NULL)
-            {
-                parser->pos = start;
-                return JSMN_ERROR_NOMEM;
-            }
-            jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos);
-#ifdef JSMN_PARENT_LINKS
-            token->parent = parser->toksuper;
-#endif
-            return 0;
-        }
-
-        if (c == '\\' && (parser->pos + 1) < len)
-        {
-            parser->pos++;
-            char esc = furi_string_get_char(js, parser->pos);
-            switch (esc)
-            {
-            case '\"':
-            case '/':
-            case '\\':
-            case 'b':
-            case 'f':
-            case 'r':
-            case 'n':
-            case 't':
-                break;
-            case 'u':
-            {
-                parser->pos++;
-                for (int i = 0; i < 4 && parser->pos < len; i++)
-                {
-                    char hex = furi_string_get_char(js, parser->pos);
-                    if (!((hex >= '0' && hex <= '9') ||
-                          (hex >= 'A' && hex <= 'F') ||
-                          (hex >= 'a' && hex <= 'f')))
-                    {
-                        parser->pos = start;
-                        return JSMN_ERROR_INVAL;
-                    }
-                    parser->pos++;
-                }
-                parser->pos--;
-                break;
-            }
-            default:
-                parser->pos = start;
-                return JSMN_ERROR_INVAL;
-            }
-        }
-    }
-    parser->pos = start;
-    return JSMN_ERROR_PART;
-}
-
-/**
- * Create JSON parser
- */
-void jsmn_init_furi(jsmn_parser *parser)
-{
-    parser->pos = 0;
-    parser->toknext = 0;
-    parser->toksuper = -1;
-}
-
-/**
- * Parse JSON string and fill tokens.
- * Now uses FuriString for the input JSON.
- */
-int jsmn_parse_furi(jsmn_parser *parser, const FuriString *js,
-                    jsmntok_t *tokens, const unsigned int num_tokens)
-{
-    size_t len = furi_string_size(js);
-    int r;
-    int i;
-    int count = parser->toknext;
-
-    for (; parser->pos < len; parser->pos++)
-    {
-        char c = furi_string_get_char(js, parser->pos);
-        jsmntype_t type;
-
-        switch (c)
-        {
-        case '{':
-        case '[':
-        {
-            count++;
-            if (tokens == NULL)
-            {
-                break;
-            }
-            jsmntok_t *token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if (token == NULL)
-                return JSMN_ERROR_NOMEM;
-            if (parser->toksuper != -1)
-            {
-                jsmntok_t *t = &tokens[parser->toksuper];
-#ifdef JSMN_STRICT
-                if (t->type == JSMN_OBJECT)
-                    return JSMN_ERROR_INVAL;
-#endif
-                t->size++;
-#ifdef JSMN_PARENT_LINKS
-                token->parent = parser->toksuper;
-#endif
-            }
-            token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
-            token->start = parser->pos;
-            parser->toksuper = parser->toknext - 1;
-            break;
-        }
-        case '}':
-        case ']':
-            if (tokens == NULL)
-            {
-                break;
-            }
-            type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
-#ifdef JSMN_PARENT_LINKS
-            if (parser->toknext < 1)
-            {
-                return JSMN_ERROR_INVAL;
-            }
-            {
-                jsmntok_t *token = &tokens[parser->toknext - 1];
-                for (;;)
-                {
-                    if (token->start != -1 && token->end == -1)
-                    {
-                        if (token->type != type)
-                            return JSMN_ERROR_INVAL;
-                        token->end = parser->pos + 1;
-                        parser->toksuper = token->parent;
-                        break;
-                    }
-                    if (token->parent == -1)
-                    {
-                        if (token->type != type || parser->toksuper == -1)
-                        {
-                            return JSMN_ERROR_INVAL;
-                        }
-                        break;
-                    }
-                    token = &tokens[token->parent];
-                }
-            }
-#else
-            {
-                jsmntok_t *token;
-                for (i = parser->toknext - 1; i >= 0; i--)
-                {
-                    token = &tokens[i];
-                    if (token->start != -1 && token->end == -1)
-                    {
-                        if (token->type != type)
-                            return JSMN_ERROR_INVAL;
-                        parser->toksuper = -1;
-                        token->end = parser->pos + 1;
-                        break;
-                    }
-                }
-                if (i == -1)
-                    return JSMN_ERROR_INVAL;
-                for (; i >= 0; i--)
-                {
-                    token = &tokens[i];
-                    if (token->start != -1 && token->end == -1)
-                    {
-                        parser->toksuper = i;
-                        break;
-                    }
-                }
-            }
-#endif
-            break;
-        case '\"':
-            r = jsmn_parse_string(parser, js, tokens, num_tokens);
-            if (r < 0)
-                return r;
-            count++;
-            if (parser->toksuper != -1 && tokens != NULL)
-            {
-                tokens[parser->toksuper].size++;
-            }
-            break;
-        case '\t':
-        case '\r':
-        case '\n':
-        case ' ':
-            // Whitespace - ignore
-            break;
-        case ':':
-            parser->toksuper = parser->toknext - 1;
-            break;
-        case ',':
-            if (tokens != NULL && parser->toksuper != -1 &&
-                tokens[parser->toksuper].type != JSMN_ARRAY &&
-                tokens[parser->toksuper].type != JSMN_OBJECT)
-            {
-#ifdef JSMN_PARENT_LINKS
-                parser->toksuper = tokens[parser->toksuper].parent;
-#else
-                for (i = parser->toknext - 1; i >= 0; i--)
-                {
-                    if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT)
-                    {
-                        if (tokens[i].start != -1 && tokens[i].end == -1)
-                        {
-                            parser->toksuper = i;
-                            break;
-                        }
-                    }
-                }
-#endif
-            }
-            break;
-#ifdef JSMN_STRICT
-        case '-':
-        case '0':
-        case '1':
-        case '2':
-        case '3':
-        case '4':
-        case '5':
-        case '6':
-        case '7':
-        case '8':
-        case '9':
-        case 't':
-        case 'f':
-        case 'n':
-            if (tokens != NULL && parser->toksuper != -1)
-            {
-                const jsmntok_t *t = &tokens[parser->toksuper];
-                if (t->type == JSMN_OBJECT ||
-                    (t->type == JSMN_STRING && t->size != 0))
-                {
-                    return JSMN_ERROR_INVAL;
-                }
-            }
-#else
-        default:
-#endif
-            r = jsmn_parse_primitive(parser, js, tokens, num_tokens);
-            if (r < 0)
-                return r;
-            count++;
-            if (parser->toksuper != -1 && tokens != NULL)
-            {
-                tokens[parser->toksuper].size++;
-            }
-            break;
-#ifdef JSMN_STRICT
-        default:
-            return JSMN_ERROR_INVAL;
-#endif
-        }
-    }
-
-    if (tokens != NULL)
-    {
-        for (i = parser->toknext - 1; i >= 0; i--)
-        {
-            if (tokens[i].start != -1 && tokens[i].end == -1)
-            {
-                return JSMN_ERROR_PART;
-            }
-        }
-    }
-
-    return count;
-}
-
-// Helper function to create a JSON object: {"key":"value"}
-FuriString *get_json_furi(const FuriString *key, const FuriString *value)
-{
-    FuriString *result = furi_string_alloc();
-    furi_string_printf(result, "{\"%s\":\"%s\"}",
-                       furi_string_get_cstr(key),
-                       furi_string_get_cstr(value));
-    return result; // Caller responsible for furi_string_free
-}
-
-// Helper function to compare JSON keys
-static int jsoneq_furi(const FuriString *json, jsmntok_t *tok, const FuriString *s)
-{
-    size_t s_len = furi_string_size(s);
-    size_t tok_len = tok->end - tok->start;
-
-    if (tok->type != JSMN_STRING)
-        return -1;
-    if (s_len != tok_len)
-        return -1;
-
-    FuriString *sub = furi_string_alloc_set(json);
-    furi_string_mid(sub, tok->start, tok_len);
-
-    int res = furi_string_cmp(sub, s);
-    furi_string_free(sub);
-
-    return (res == 0) ? 0 : -1;
-}
-
-// Skip a token and its descendants
-static int skip_token(const jsmntok_t *tokens, int start, int total)
-{
-    if (start < 0 || start >= total)
-        return -1;
-
-    int i = start;
-    if (tokens[i].type == JSMN_OBJECT)
-    {
-        int pairs = tokens[i].size;
-        i++;
-        for (int p = 0; p < pairs; p++)
-        {
-            i++; // skip key
-            if (i >= total)
-                return -1;
-            i = skip_token(tokens, i, total); // skip value
-            if (i == -1)
-                return -1;
-        }
-        return i;
-    }
-    else if (tokens[i].type == JSMN_ARRAY)
-    {
-        int elems = tokens[i].size;
-        i++;
-        for (int e = 0; e < elems; e++)
-        {
-            i = skip_token(tokens, i, total);
-            if (i == -1)
-                return -1;
-        }
-        return i;
-    }
-    else
-    {
-        return i + 1;
-    }
-}
-
-/**
- * Parse JSON and return the value associated with a given char* key.
- */
-FuriString *get_json_value_furi(const char *key, const FuriString *json_data)
-{
-    if (json_data == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "JSON data is NULL");
-        return NULL;
-    }
-    uint32_t max_tokens = json_token_count_furi(json_data);
-    if (!jsmn_memory_check(sizeof(jsmntok_t) * max_tokens))
-    {
-        FURI_LOG_E("JSMM.H", "Insufficient memory for JSON tokens.");
-        return NULL;
-    }
-    // Create a temporary FuriString from key
-    FuriString *key_str = furi_string_alloc();
-    furi_string_cat_str(key_str, key);
-
-    jsmn_parser parser;
-    jsmn_init_furi(&parser);
-
-    jsmntok_t *tokens = (jsmntok_t *)malloc(sizeof(jsmntok_t) * max_tokens);
-    if (tokens == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
-        furi_string_free(key_str);
-        return NULL;
-    }
-
-    int ret = jsmn_parse_furi(&parser, json_data, tokens, max_tokens);
-    if (ret < 0)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to parse JSON: %d", ret);
-        free(tokens);
-        furi_string_free(key_str);
-        return NULL;
-    }
-
-    if (ret < 1 || tokens[0].type != JSMN_OBJECT)
-    {
-        FURI_LOG_E("JSMM.H", "Root element is not an object.");
-        free(tokens);
-        furi_string_free(key_str);
-        return NULL;
-    }
-
-    for (int i = 1; i < ret; i++)
-    {
-        if (jsoneq_furi(json_data, &tokens[i], key_str) == 0)
-        {
-            int length = tokens[i + 1].end - tokens[i + 1].start;
-            FuriString *value = furi_string_alloc_set(json_data);
-            furi_string_mid(value, tokens[i + 1].start, length);
-            free(tokens);
-            furi_string_free(key_str);
-            return value;
-        }
-    }
-
-    free(tokens);
-    furi_string_free(key_str);
-    char warning[128];
-    snprintf(warning, sizeof(warning), "Failed to find the key \"%s\" in the JSON.", key);
-    FURI_LOG_E("JSMM.H", warning);
-    return NULL;
-}
-
-/**
- * Return the value at a given index in a JSON array for a given char* key.
- */
-FuriString *get_json_array_value_furi(const char *key, uint32_t index, const FuriString *json_data)
-{
-    FuriString *array_str = get_json_value_furi(key, json_data);
-    if (array_str == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to get array for key");
-        return NULL;
-    }
-    uint32_t max_tokens = json_token_count_furi(array_str);
-    if (!jsmn_memory_check(sizeof(jsmntok_t) * max_tokens))
-    {
-        FURI_LOG_E("JSMM.H", "Insufficient memory for JSON tokens.");
-        furi_string_free(array_str);
-        return NULL;
-    }
-    jsmn_parser parser;
-    jsmn_init_furi(&parser);
-
-    jsmntok_t *tokens = (jsmntok_t *)malloc(sizeof(jsmntok_t) * max_tokens);
-    if (tokens == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
-        furi_string_free(array_str);
-        return NULL;
-    }
-
-    int ret = jsmn_parse_furi(&parser, array_str, tokens, max_tokens);
-    if (ret < 0)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
-        free(tokens);
-        furi_string_free(array_str);
-        return NULL;
-    }
-
-    if (ret < 1 || tokens[0].type != JSMN_ARRAY)
-    {
-        FURI_LOG_E("JSMM.H", "Value for key is not an array.");
-        free(tokens);
-        furi_string_free(array_str);
-        return NULL;
-    }
-
-    if (index >= (uint32_t)tokens[0].size)
-    {
-        // FURI_LOG_E("JSMM.H", "Index %lu out of bounds for array with size %u.", index, tokens[0].size);
-        free(tokens);
-        furi_string_free(array_str);
-        return NULL;
-    }
-
-    int elem_token = 1;
-    for (uint32_t i = 0; i < index; i++)
-    {
-        elem_token = skip_token(tokens, elem_token, ret);
-        if (elem_token == -1 || elem_token >= ret)
-        {
-            FURI_LOG_E("JSMM.H", "Error skipping tokens to reach element %lu.", i);
-            free(tokens);
-            furi_string_free(array_str);
-            return NULL;
-        }
-    }
-
-    jsmntok_t element = tokens[elem_token];
-    int length = element.end - element.start;
-
-    FuriString *value = furi_string_alloc_set(array_str);
-    furi_string_mid(value, element.start, length);
-
-    free(tokens);
-    furi_string_free(array_str);
-
-    return value;
-}
-
-/**
- * Extract all object values from a JSON array associated with a given char* key.
- */
-FuriString **get_json_array_values_furi(const char *key, const FuriString *json_data, int *num_values)
-{
-    *num_values = 0;
-    // Convert key to FuriString and call get_json_value_furi
-    FuriString *array_str = get_json_value_furi(key, json_data);
-    if (array_str == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to get array for key");
-        return NULL;
-    }
-
-    uint32_t max_tokens = json_token_count_furi(array_str);
-    if (!jsmn_memory_check(sizeof(jsmntok_t) * max_tokens))
-    {
-        FURI_LOG_E("JSMM.H", "Insufficient memory for JSON tokens.");
-        furi_string_free(array_str);
-        return NULL;
-    }
-    jsmn_parser parser;
-    jsmn_init_furi(&parser);
-
-    jsmntok_t *tokens = (jsmntok_t *)malloc(sizeof(jsmntok_t) * max_tokens);
-    if (tokens == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
-        furi_string_free(array_str);
-        return NULL;
-    }
-
-    int ret = jsmn_parse_furi(&parser, array_str, tokens, max_tokens);
-    if (ret < 0)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
-        free(tokens);
-        furi_string_free(array_str);
-        return NULL;
-    }
-
-    if (tokens[0].type != JSMN_ARRAY)
-    {
-        FURI_LOG_E("JSMM.H", "Value for key is not an array.");
-        free(tokens);
-        furi_string_free(array_str);
-        return NULL;
-    }
-
-    int array_size = tokens[0].size;
-    FuriString **values = (FuriString **)malloc(array_size * sizeof(FuriString *));
-    if (values == NULL)
-    {
-        FURI_LOG_E("JSMM.H", "Failed to allocate memory for array of values.");
-        free(tokens);
-        furi_string_free(array_str);
-        return NULL;
-    }
-
-    int actual_num_values = 0;
-    int current_token = 1;
-    for (int i = 0; i < array_size; i++)
-    {
-        if (current_token >= ret)
-        {
-            FURI_LOG_E("JSMM.H", "Unexpected end of tokens while traversing array.");
-            break;
-        }
-
-        jsmntok_t element = tokens[current_token];
-
-        int length = element.end - element.start;
-        FuriString *value = furi_string_alloc_set(array_str);
-        furi_string_mid(value, element.start, length);
-
-        values[actual_num_values] = value;
-        actual_num_values++;
-
-        // Skip this element and its descendants
-        current_token = skip_token(tokens, current_token, ret);
-        if (current_token == -1)
-        {
-            FURI_LOG_E("JSMM.H", "Error skipping tokens after element %d.", i);
-            break;
-        }
-    }
-
-    *num_values = actual_num_values;
-    if (actual_num_values < array_size)
-    {
-        FuriString **reduced_values = (FuriString **)realloc(values, actual_num_values * sizeof(FuriString *));
-        if (reduced_values != NULL)
-        {
-            values = reduced_values;
-        }
-    }
-
-    free(tokens);
-    furi_string_free(array_str);
-    return values;
-}
-
-uint32_t json_token_count_furi(const FuriString *json)
-{
-    if (json == NULL)
-    {
-        return JSMN_ERROR_INVAL;
-    }
-
-    jsmn_parser parser;
-    jsmn_init_furi(&parser);
-
-    // Pass NULL for tokens and 0 for num_tokens to get the token count only
-    int ret = jsmn_parse_furi(&parser, json, NULL, 0);
-    return ret; // If ret >= 0, it represents the number of tokens needed.
-}

+ 0 - 74
jsmn/jsmn_furi.h

@@ -1,74 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2010 Serge Zaitsev
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * [License text continues...]
- */
-
-#ifndef JSMN_FURI_H
-#define JSMN_FURI_H
-
-#include <jsmn/jsmn_h.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#ifdef JSMN_STATIC
-#define JSMN_API static
-#else
-#define JSMN_API extern
-#endif
-
-    JSMN_API void jsmn_init_furi(jsmn_parser *parser);
-    JSMN_API int jsmn_parse_furi(jsmn_parser *parser, const FuriString *js,
-                                 jsmntok_t *tokens, const unsigned int num_tokens);
-
-#ifndef JSMN_HEADER
-/* Implementation in jsmn_furi.c */
-#endif /* JSMN_HEADER */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* JSMN_FURI_H */
-
-#ifndef JB_JSMN_FURI_EDIT
-#define JB_JSMN_FURI_EDIT
-
-// Helper function to create a JSON object
-FuriString *get_json_furi(const FuriString *key, const FuriString *value);
-
-// Updated signatures to accept const char* key
-FuriString *get_json_value_furi(const char *key, const FuriString *json_data);
-FuriString *get_json_array_value_furi(const char *key, uint32_t index, const FuriString *json_data);
-FuriString **get_json_array_values_furi(const char *key, const FuriString *json_data, int *num_values);
-
-uint32_t json_token_count_furi(const FuriString *json);
-/* Example usage:
-char *json = "{\"key1\":\"value1\",\"key2\":\"value2\"}";
-FuriString *json_data = char_to_furi_string(json);
-if (!json_data)
-{
-    FURI_LOG_E(TAG, "Failed to allocate FuriString");
-    return -1;
-}
-FuriString *value = get_json_value_furi("key1", json_data, json_token_count_furi(json_data));
-if (value)
-{
-    FURI_LOG_I(TAG, "Value: %s", furi_string_get_cstr(value));
-    furi_string_free(value);
-}
-furi_string_free(json_data);
-*/
-#endif /* JB_JSMN_EDIT */

+ 0 - 15
jsmn/jsmn_h.c

@@ -1,15 +0,0 @@
-#include <jsmn/jsmn_h.h>
-FuriString *char_to_furi_string(const char *str)
-{
-    FuriString *furi_str = furi_string_alloc();
-    if (!furi_str)
-    {
-        return NULL;
-    }
-    for (size_t i = 0; i < strlen(str); i++)
-    {
-        furi_string_push_back(furi_str, str[i]);
-    }
-    return furi_str;
-}
-bool jsmn_memory_check(size_t heap_size) { return memmgr_get_free_heap() > (heap_size + 1024); }

+ 0 - 56
jsmn/jsmn_h.h

@@ -1,56 +0,0 @@
-#pragma once
-#include <furi.h>
-#include <stddef.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-typedef enum
-{
-    JSMN_UNDEFINED = 0,
-    JSMN_OBJECT = 1 << 0,
-    JSMN_ARRAY = 1 << 1,
-    JSMN_STRING = 1 << 2,
-    JSMN_PRIMITIVE = 1 << 3
-} jsmntype_t;
-
-enum jsmnerr
-{
-    JSMN_ERROR_NOMEM = -1,
-    JSMN_ERROR_INVAL = -2,
-    JSMN_ERROR_PART = -3
-};
-
-typedef struct
-{
-    jsmntype_t type;
-    int start;
-    int end;
-    int size;
-#ifdef JSMN_PARENT_LINKS
-    int parent;
-#endif
-} jsmntok_t;
-
-typedef struct
-{
-    unsigned int pos;     /* offset in the JSON string */
-    unsigned int toknext; /* next token to allocate */
-    int toksuper;         /* superior token node, e.g. parent object or array */
-} jsmn_parser;
-
-typedef struct
-{
-    char *key;
-    char *value;
-} JSON;
-
-typedef struct
-{
-    FuriString *key;
-    FuriString *value;
-} FuriJSON;
-
-FuriString *char_to_furi_string(const char *str);
-
-// check memory
-bool jsmn_memory_check(size_t heap_size);

+ 0 - 784
text_input/uart_text_input.c

@@ -1,784 +0,0 @@
-// from https://github.com/xMasterX/all-the-plugins/blob/dev/base_pack/uart_terminal/uart_text_input.c
-// all credits to xMasterX for the code
-#include "uart_text_input.h"
-#include <gui/elements.h>
-#include "flip_store_icons.h"
-#include <furi.h>
-
-struct UART_TextInput
-{
-    View *view;
-    FuriTimer *timer;
-};
-
-typedef struct
-{
-    const char text;
-    const uint8_t x;
-    const uint8_t y;
-} UART_TextInputKey;
-
-typedef struct
-{
-    const char *header;
-    char *text_buffer;
-    size_t text_buffer_size;
-    bool clear_default_text;
-
-    UART_TextInputCallback callback;
-    void *callback_context;
-
-    uint8_t selected_row;
-    uint8_t selected_column;
-
-    UART_TextInputValidatorCallback validator_callback;
-    void *validator_callback_context;
-    FuriString *validator_text;
-    bool valadator_message_visible;
-} UART_TextInputModel;
-
-static const uint8_t keyboard_origin_x = 1;
-static const uint8_t keyboard_origin_y = 29;
-static const uint8_t keyboard_row_count = 4;
-
-#define mode_AT "Send AT command to UART"
-
-#define ENTER_KEY '\r'
-#define BACKSPACE_KEY '\b'
-
-static const UART_TextInputKey keyboard_keys_row_1[] = {
-    {'{', 1, 0},
-    {'(', 9, 0},
-    {'[', 17, 0},
-    {'|', 25, 0},
-    {'@', 33, 0},
-    {'&', 41, 0},
-    {'#', 49, 0},
-    {';', 57, 0},
-    {'^', 65, 0},
-    {'*', 73, 0},
-    {'`', 81, 0},
-    {'"', 89, 0},
-    {'~', 97, 0},
-    {'\'', 105, 0},
-    {'.', 113, 0},
-    {'/', 120, 0},
-};
-
-static const UART_TextInputKey keyboard_keys_row_2[] = {
-    {'q', 1, 10},
-    {'w', 9, 10},
-    {'e', 17, 10},
-    {'r', 25, 10},
-    {'t', 33, 10},
-    {'y', 41, 10},
-    {'u', 49, 10},
-    {'i', 57, 10},
-    {'o', 65, 10},
-    {'p', 73, 10},
-    {'0', 81, 10},
-    {'1', 89, 10},
-    {'2', 97, 10},
-    {'3', 105, 10},
-    {'=', 113, 10},
-    {'-', 120, 10},
-};
-
-static const UART_TextInputKey keyboard_keys_row_3[] = {
-    {'a', 1, 21},
-    {'s', 9, 21},
-    {'d', 18, 21},
-    {'f', 25, 21},
-    {'g', 33, 21},
-    {'h', 41, 21},
-    {'j', 49, 21},
-    {'k', 57, 21},
-    {'l', 65, 21},
-    {BACKSPACE_KEY, 72, 13},
-    {'4', 89, 21},
-    {'5', 97, 21},
-    {'6', 105, 21},
-    {'$', 113, 21},
-    {'%', 120, 21},
-
-};
-
-static const UART_TextInputKey keyboard_keys_row_4[] = {
-    {'z', 1, 33},
-    {'x', 9, 33},
-    {'c', 18, 33},
-    {'v', 25, 33},
-    {'b', 33, 33},
-    {'n', 41, 33},
-    {'m', 49, 33},
-    {'_', 57, 33},
-    {ENTER_KEY, 64, 24},
-    {'7', 89, 33},
-    {'8', 97, 33},
-    {'9', 105, 33},
-    {'!', 113, 33},
-    {'+', 120, 33},
-};
-
-static uint8_t get_row_size(uint8_t row_index)
-{
-    uint8_t row_size = 0;
-
-    switch (row_index + 1)
-    {
-    case 1:
-        row_size = sizeof(keyboard_keys_row_1) / sizeof(UART_TextInputKey);
-        break;
-    case 2:
-        row_size = sizeof(keyboard_keys_row_2) / sizeof(UART_TextInputKey);
-        break;
-    case 3:
-        row_size = sizeof(keyboard_keys_row_3) / sizeof(UART_TextInputKey);
-        break;
-    case 4:
-        row_size = sizeof(keyboard_keys_row_4) / sizeof(UART_TextInputKey);
-        break;
-    }
-
-    return row_size;
-}
-
-static const UART_TextInputKey *get_row(uint8_t row_index)
-{
-    const UART_TextInputKey *row = NULL;
-
-    switch (row_index + 1)
-    {
-    case 1:
-        row = keyboard_keys_row_1;
-        break;
-    case 2:
-        row = keyboard_keys_row_2;
-        break;
-    case 3:
-        row = keyboard_keys_row_3;
-        break;
-    case 4:
-        row = keyboard_keys_row_4;
-        break;
-    }
-
-    return row;
-}
-
-static char get_selected_char(UART_TextInputModel *model)
-{
-    return get_row(model->selected_row)[model->selected_column].text;
-}
-
-static bool char_is_lowercase(char letter)
-{
-    return (letter >= 0x61 && letter <= 0x7A);
-}
-
-static bool char_is_uppercase(char letter)
-{
-    return (letter >= 0x41 && letter <= 0x5A);
-}
-
-static char char_to_lowercase(const char letter)
-{
-    switch (letter)
-    {
-    case ' ':
-        return 0x5f;
-        break;
-    case ')':
-        return 0x28;
-        break;
-    case '}':
-        return 0x7b;
-        break;
-    case ']':
-        return 0x5b;
-        break;
-    case '\\':
-        return 0x2f;
-        break;
-    case ':':
-        return 0x3b;
-        break;
-    case ',':
-        return 0x2e;
-        break;
-    case '?':
-        return 0x21;
-        break;
-    case '>':
-        return 0x3c;
-        break;
-    }
-    if (char_is_uppercase(letter))
-    {
-        return (letter + 0x20);
-    }
-    else
-    {
-        return letter;
-    }
-}
-
-static char char_to_uppercase(const char letter)
-{
-    switch (letter)
-    {
-    case '_':
-        return 0x20;
-        break;
-    case '(':
-        return 0x29;
-        break;
-    case '{':
-        return 0x7d;
-        break;
-    case '[':
-        return 0x5d;
-        break;
-    case '/':
-        return 0x5c;
-        break;
-    case ';':
-        return 0x3a;
-        break;
-    case '.':
-        return 0x2c;
-        break;
-    case '!':
-        return 0x3f;
-        break;
-    case '<':
-        return 0x3e;
-        break;
-    }
-    if (char_is_lowercase(letter))
-    {
-        return (letter - 0x20);
-    }
-    else
-    {
-        return letter;
-    }
-}
-
-static void uart_text_input_backspace_cb(UART_TextInputModel *model)
-{
-    uint8_t text_length = model->clear_default_text ? 1 : strlen(model->text_buffer);
-    if (text_length > 0)
-    {
-        model->text_buffer[text_length - 1] = 0;
-    }
-}
-
-static void uart_text_input_view_draw_callback(Canvas *canvas, void *_model)
-{
-    UART_TextInputModel *model = _model;
-    // uint8_t text_length = model->text_buffer ? strlen(model->text_buffer) : 0;
-    uint8_t needed_string_width = canvas_width(canvas) - 8;
-    uint8_t start_pos = 4;
-
-    const char *text = model->text_buffer;
-
-    canvas_clear(canvas);
-    canvas_set_color(canvas, ColorBlack);
-
-    canvas_draw_str(canvas, 2, 7, model->header);
-    elements_slightly_rounded_frame(canvas, 1, 8, 126, 12);
-
-    if (canvas_string_width(canvas, text) > needed_string_width)
-    {
-        canvas_draw_str(canvas, start_pos, 17, "...");
-        start_pos += 6;
-        needed_string_width -= 8;
-    }
-
-    while (text != 0 && canvas_string_width(canvas, text) > needed_string_width)
-    {
-        text++;
-    }
-
-    if (model->clear_default_text)
-    {
-        elements_slightly_rounded_box(
-            canvas, start_pos - 1, 14, canvas_string_width(canvas, text) + 2, 10);
-        canvas_set_color(canvas, ColorWhite);
-    }
-    else
-    {
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 1, 18, "|");
-        canvas_draw_str(canvas, start_pos + canvas_string_width(canvas, text) + 2, 18, "|");
-    }
-    canvas_draw_str(canvas, start_pos, 17, text);
-
-    canvas_set_font(canvas, FontKeyboard);
-
-    for (uint8_t row = 0; row <= keyboard_row_count; row++)
-    {
-        const uint8_t column_count = get_row_size(row);
-        const UART_TextInputKey *keys = get_row(row);
-
-        for (size_t column = 0; column < column_count; column++)
-        {
-            if (keys[column].text == ENTER_KEY)
-            {
-                canvas_set_color(canvas, ColorBlack);
-                if (model->selected_row == row && model->selected_column == column)
-                {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySaveSelected_24x11);
-                }
-                else
-                {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeySave_24x11);
-                }
-            }
-            else if (keys[column].text == BACKSPACE_KEY)
-            {
-                canvas_set_color(canvas, ColorBlack);
-                if (model->selected_row == row && model->selected_column == column)
-                {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspaceSelected_16x9);
-                }
-                else
-                {
-                    canvas_draw_icon(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        &I_KeyBackspace_16x9);
-                }
-            }
-            else
-            {
-                if (model->selected_row == row && model->selected_column == column)
-                {
-                    canvas_set_color(canvas, ColorBlack);
-                    canvas_draw_box(
-                        canvas,
-                        keyboard_origin_x + keys[column].x - 1,
-                        keyboard_origin_y + keys[column].y - 8,
-                        7,
-                        10);
-                    canvas_set_color(canvas, ColorWhite);
-                }
-                else
-                {
-                    canvas_set_color(canvas, ColorBlack);
-                }
-                if (0 == strcmp(model->header, mode_AT))
-                {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        char_to_uppercase(keys[column].text));
-                }
-                else
-                {
-                    canvas_draw_glyph(
-                        canvas,
-                        keyboard_origin_x + keys[column].x,
-                        keyboard_origin_y + keys[column].y,
-                        keys[column].text);
-                }
-            }
-        }
-    }
-    if (model->valadator_message_visible)
-    {
-        canvas_set_font(canvas, FontSecondary);
-        canvas_set_color(canvas, ColorWhite);
-        canvas_draw_box(canvas, 8, 10, 110, 48);
-        canvas_set_color(canvas, ColorBlack);
-        canvas_draw_icon(canvas, 10, 14, &I_WarningDolphin_45x42);
-        canvas_draw_rframe(canvas, 8, 8, 112, 50, 3);
-        canvas_draw_rframe(canvas, 9, 9, 110, 48, 2);
-        elements_multiline_text(canvas, 62, 20, furi_string_get_cstr(model->validator_text));
-        canvas_set_font(canvas, FontKeyboard);
-    }
-}
-
-static void
-uart_text_input_handle_up(UART_TextInput *uart_text_input, UART_TextInputModel *model)
-{
-    UNUSED(uart_text_input);
-    if (model->selected_row > 0)
-    {
-        model->selected_row--;
-        if (model->selected_column > get_row_size(model->selected_row) - 6)
-        {
-            model->selected_column = model->selected_column + 1;
-        }
-    }
-}
-
-static void
-uart_text_input_handle_down(UART_TextInput *uart_text_input, UART_TextInputModel *model)
-{
-    UNUSED(uart_text_input);
-    if (model->selected_row < keyboard_row_count - 1)
-    {
-        model->selected_row++;
-        if (model->selected_column > get_row_size(model->selected_row) - 4)
-        {
-            model->selected_column = model->selected_column - 1;
-        }
-    }
-}
-
-static void
-uart_text_input_handle_left(UART_TextInput *uart_text_input, UART_TextInputModel *model)
-{
-    UNUSED(uart_text_input);
-    if (model->selected_column > 0)
-    {
-        model->selected_column--;
-    }
-    else
-    {
-        model->selected_column = get_row_size(model->selected_row) - 1;
-    }
-}
-
-static void
-uart_text_input_handle_right(UART_TextInput *uart_text_input, UART_TextInputModel *model)
-{
-    UNUSED(uart_text_input);
-    if (model->selected_column < get_row_size(model->selected_row) - 1)
-    {
-        model->selected_column++;
-    }
-    else
-    {
-        model->selected_column = 0;
-    }
-}
-
-static void uart_text_input_handle_ok(
-    UART_TextInput *uart_text_input,
-    UART_TextInputModel *model,
-    bool shift)
-{
-    char selected = get_selected_char(model);
-    uint8_t text_length = strlen(model->text_buffer);
-
-    if (0 == strcmp(model->header, mode_AT))
-    {
-        selected = char_to_uppercase(selected);
-    }
-
-    if (shift)
-    {
-        if (0 == strcmp(model->header, mode_AT))
-        {
-            selected = char_to_lowercase(selected);
-        }
-        else
-        {
-            selected = char_to_uppercase(selected);
-        }
-    }
-
-    if (selected == ENTER_KEY)
-    {
-        if (model->validator_callback &&
-            (!model->validator_callback(
-                model->text_buffer, model->validator_text, model->validator_callback_context)))
-        {
-            model->valadator_message_visible = true;
-            furi_timer_start(uart_text_input->timer, furi_kernel_get_tick_frequency() * 4);
-        }
-        else if (model->callback != 0 && text_length > 0)
-        {
-            model->callback(model->callback_context);
-        }
-    }
-    else if (selected == BACKSPACE_KEY)
-    {
-        uart_text_input_backspace_cb(model);
-    }
-    else
-    {
-        if (model->clear_default_text)
-        {
-            text_length = 0;
-        }
-        if (text_length < (model->text_buffer_size - 1))
-        {
-            model->text_buffer[text_length] = selected;
-            model->text_buffer[text_length + 1] = 0;
-        }
-    }
-    model->clear_default_text = false;
-}
-
-static bool uart_text_input_view_input_callback(InputEvent *event, void *context)
-{
-    UART_TextInput *uart_text_input = context;
-    furi_assert(uart_text_input);
-
-    bool consumed = false;
-
-    // Acquire model
-    UART_TextInputModel *model = view_get_model(uart_text_input->view);
-
-    if ((!(event->type == InputTypePress) && !(event->type == InputTypeRelease)) &&
-        model->valadator_message_visible)
-    {
-        model->valadator_message_visible = false;
-        consumed = true;
-    }
-    else if (event->type == InputTypeShort)
-    {
-        consumed = true;
-        switch (event->key)
-        {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, false);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    }
-    else if (event->type == InputTypeLong)
-    {
-        consumed = true;
-        switch (event->key)
-        {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyOk:
-            uart_text_input_handle_ok(uart_text_input, model, true);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    }
-    else if (event->type == InputTypeRepeat)
-    {
-        consumed = true;
-        switch (event->key)
-        {
-        case InputKeyUp:
-            uart_text_input_handle_up(uart_text_input, model);
-            break;
-        case InputKeyDown:
-            uart_text_input_handle_down(uart_text_input, model);
-            break;
-        case InputKeyLeft:
-            uart_text_input_handle_left(uart_text_input, model);
-            break;
-        case InputKeyRight:
-            uart_text_input_handle_right(uart_text_input, model);
-            break;
-        case InputKeyBack:
-            uart_text_input_backspace_cb(model);
-            break;
-        default:
-            consumed = false;
-            break;
-        }
-    }
-
-    // Commit model
-    view_commit_model(uart_text_input->view, consumed);
-
-    return consumed;
-}
-
-void uart_text_input_timer_callback(void *context)
-{
-    furi_assert(context);
-    UART_TextInput *uart_text_input = context;
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->valadator_message_visible = false; },
-        true);
-}
-
-UART_TextInput *uart_text_input_alloc()
-{
-    UART_TextInput *uart_text_input = malloc(sizeof(UART_TextInput));
-    uart_text_input->view = view_alloc();
-    view_set_context(uart_text_input->view, uart_text_input);
-    view_allocate_model(uart_text_input->view, ViewModelTypeLocking, sizeof(UART_TextInputModel));
-    view_set_draw_callback(uart_text_input->view, uart_text_input_view_draw_callback);
-    view_set_input_callback(uart_text_input->view, uart_text_input_view_input_callback);
-
-    uart_text_input->timer =
-        furi_timer_alloc(uart_text_input_timer_callback, FuriTimerTypeOnce, uart_text_input);
-
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { model->validator_text = furi_string_alloc(); },
-        false);
-
-    uart_text_input_reset(uart_text_input);
-
-    return uart_text_input;
-}
-
-void uart_text_input_free(UART_TextInput *uart_text_input)
-{
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { furi_string_free(model->validator_text); },
-        false);
-
-    // Send stop command
-    furi_timer_stop(uart_text_input->timer);
-    // Release allocated memory
-    furi_timer_free(uart_text_input->timer);
-
-    view_free(uart_text_input->view);
-
-    free(uart_text_input);
-}
-
-void uart_text_input_reset(UART_TextInput *uart_text_input)
-{
-    furi_assert(uart_text_input);
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->text_buffer_size = 0;
-            model->header = "";
-            model->selected_row = 0;
-            model->selected_column = 0;
-            model->clear_default_text = false;
-            model->text_buffer = NULL;
-            model->text_buffer_size = 0;
-            model->callback = NULL;
-            model->callback_context = NULL;
-            model->validator_callback = NULL;
-            model->validator_callback_context = NULL;
-            furi_string_reset(model->validator_text);
-            model->valadator_message_visible = false;
-        },
-        true);
-}
-
-View *uart_text_input_get_view(UART_TextInput *uart_text_input)
-{
-    furi_assert(uart_text_input);
-    return uart_text_input->view;
-}
-
-void uart_text_input_set_result_callback(
-    UART_TextInput *uart_text_input,
-    UART_TextInputCallback callback,
-    void *callback_context,
-    char *text_buffer,
-    size_t text_buffer_size,
-    bool clear_default_text)
-{
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->callback = callback;
-            model->callback_context = callback_context;
-            model->text_buffer = text_buffer;
-            model->text_buffer_size = text_buffer_size;
-            model->clear_default_text = clear_default_text;
-            if (text_buffer && text_buffer[0] != '\0')
-            {
-                // Set focus on Save
-                model->selected_row = 2;
-                model->selected_column = 8;
-            }
-        },
-        true);
-}
-
-void uart_text_input_set_validator(
-    UART_TextInput *uart_text_input,
-    UART_TextInputValidatorCallback callback,
-    void *callback_context)
-{
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        {
-            model->validator_callback = callback;
-            model->validator_callback_context = callback_context;
-        },
-        true);
-}
-
-UART_TextInputValidatorCallback
-uart_text_input_get_validator_callback(UART_TextInput *uart_text_input)
-{
-    UART_TextInputValidatorCallback validator_callback = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback = model->validator_callback; },
-        false);
-    return validator_callback;
-}
-
-void *uart_text_input_get_validator_callback_context(UART_TextInput *uart_text_input)
-{
-    void *validator_callback_context = NULL;
-    with_view_model(
-        uart_text_input->view,
-        UART_TextInputModel * model,
-        { validator_callback_context = model->validator_callback_context; },
-        false);
-    return validator_callback_context;
-}
-
-void uart_text_input_set_header_text(UART_TextInput *uart_text_input, const char *text)
-{
-    with_view_model(
-        uart_text_input->view, UART_TextInputModel * model, { model->header = text; }, true);
-}

+ 0 - 83
text_input/uart_text_input.h

@@ -1,83 +0,0 @@
-#pragma once
-// from https://github.com/xMasterX/all-the-plugins/blob/dev/base_pack/uart_terminal/uart_text_input.c
-// all credits to xMasterX for the code
-#include <gui/view.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /** Text input anonymous structure */
-    typedef struct UART_TextInput UART_TextInput;
-    typedef void (*UART_TextInputCallback)(void *context);
-    typedef bool (*UART_TextInputValidatorCallback)(const char *text, FuriString *error, void *context);
-
-    /** Allocate and initialize text input
-     *
-     * This text input is used to enter string
-     *
-     * @return     UART_TextInput instance
-     */
-    UART_TextInput *uart_text_input_alloc();
-
-    /** Deinitialize and free text input
-     *
-     * @param      uart_text_input  UART_TextInput instance
-     */
-    void uart_text_input_free(UART_TextInput *uart_text_input);
-
-    /** Clean text input view Note: this function does not free memory
-     *
-     * @param      uart_text_input  Text input instance
-     */
-    void uart_text_input_reset(UART_TextInput *uart_text_input);
-
-    /** Get text input view
-     *
-     * @param      uart_text_input  UART_TextInput instance
-     *
-     * @return     View instance that can be used for embedding
-     */
-    View *uart_text_input_get_view(UART_TextInput *uart_text_input);
-
-    /** Set text input result callback
-     *
-     * @param      uart_text_input          UART_TextInput instance
-     * @param      callback            callback fn
-     * @param      callback_context    callback context
-     * @param      text_buffer         pointer to YOUR text buffer, that we going
-     *                                 to modify
-     * @param      text_buffer_size    YOUR text buffer size in bytes. Max string
-     *                                 length will be text_buffer_size-1.
-     * @param      clear_default_text  clear text from text_buffer on first OK
-     *                                 event
-     */
-    void uart_text_input_set_result_callback(
-        UART_TextInput *uart_text_input,
-        UART_TextInputCallback callback,
-        void *callback_context,
-        char *text_buffer,
-        size_t text_buffer_size,
-        bool clear_default_text);
-
-    void uart_text_input_set_validator(
-        UART_TextInput *uart_text_input,
-        UART_TextInputValidatorCallback callback,
-        void *callback_context);
-
-    UART_TextInputValidatorCallback
-    uart_text_input_get_validator_callback(UART_TextInput *uart_text_input);
-
-    void *uart_text_input_get_validator_callback_context(UART_TextInput *uart_text_input);
-
-    /** Set text input header text
-     *
-     * @param      uart_text_input  UART_TextInput instance
-     * @param      text        text to be shown
-     */
-    void uart_text_input_set_header_text(UART_TextInput *uart_text_input, const char *text);
-
-#ifdef __cplusplus
-}
-#endif