Explorar el Código

fix uart related plugins to disable expansion protocol

MX hace 1 año
padre
commit
0875b3c485

+ 13 - 0
apps_source_code/airmon/airmon.c

@@ -5,6 +5,8 @@
 #include <core/thread.h>
 #include <core/kernel.h>
 
+#include <expansion/expansion.h>
+
 #include "airmon_icons.h"
 #include "airmon_pms.h"
 #include "airmon_aqi.h"
@@ -236,9 +238,16 @@ static void airmon_context_free(AirmonContext* ctx) {
 int32_t airmon_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     // Allocate all of the necessary structures
     AirmonContext* ctx = airmon_context_alloc();
     if(!ctx) {
+        // Return previous state of expansion
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -247,6 +256,10 @@ int32_t airmon_app(void* p) {
 
     // Release all resources
     airmon_context_free(ctx);
+    
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
 
     return 0;
 }

+ 11 - 0
base_pack/camera_suite/camera_suite.c

@@ -1,5 +1,6 @@
 #include "camera_suite.h"
 #include <stdlib.h>
+#include <expansion/expansion.h>
 
 bool camera_suite_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -122,6 +123,11 @@ void camera_suite_app_free(CameraSuite* app) {
 /** Main entry point for initialization. */
 int32_t camera_suite_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     CameraSuite* app = camera_suite_app_alloc();
     view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
     // Init with start scene.
@@ -131,5 +137,10 @@ int32_t camera_suite_app(void* p) {
     camera_suite_save_settings(app);
     furi_hal_power_suppress_charge_exit();
     camera_suite_app_free(app);
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 12 - 0
base_pack/dap_link/dap_link.c

@@ -9,6 +9,8 @@
 #include <stm32wbxx_ll_usart.h>
 #include <stm32wbxx_ll_lpuart.h>
 
+#include <expansion/expansion.h>
+
 #include "dap_link.h"
 #include "dap_config.h"
 #include "gui/dap_gui.h"
@@ -510,6 +512,9 @@ DapConfig* dap_app_get_config(DapApp* app) {
 
 int32_t dap_link_app(void* p) {
     UNUSED(p);
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
 
     if(furi_hal_usb_is_locked()) {
         DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
@@ -526,6 +531,9 @@ int32_t dap_link_app(void* p) {
         dialog_message_show(dialogs, message);
         dialog_message_free(message);
         furi_record_close(RECORD_DIALOGS);
+        // Return previous state of expansion
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return -1;
     }
 
@@ -551,5 +559,9 @@ int32_t dap_link_app(void* p) {
     // free app
     dap_app_free(app);
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 12 - 0
base_pack/esp8266_deauth/esp8266_deauth.c

@@ -6,6 +6,7 @@
 #include <gui/canvas_i.h>
 #include <gui/gui.h>
 #include <input/input.h>
+#include <expansion/expansion.h>
 //#include <math.h>
 //#include <notification/notification.h>
 //#include <notification/notification_messages.h>
@@ -315,6 +316,10 @@ static int32_t uart_worker(void* context) {
 int32_t esp8266_deauth_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     DEAUTH_APP_LOG_I("Init");
 
     // FuriTimer* timer = furi_timer_alloc(blink_test_update, FuriTimerTypePeriodic, event_queue);
@@ -363,6 +368,9 @@ int32_t esp8266_deauth_app(void* p) {
     if(!app->mutex) {
         DEAUTH_APP_LOG_E("cannot create mutex\r\n");
         free(app);
+        // Return previous state of expansion
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -541,5 +549,9 @@ int32_t esp8266_deauth_app(void* p) {
     }
 #endif
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 12 - 0
base_pack/gps_nmea_uart/gps.c

@@ -4,6 +4,7 @@
 #include <furi.h>
 #include <gui/gui.h>
 #include <string.h>
+#include <expansion/expansion.h>
 
 typedef enum {
     EventTypeTick,
@@ -131,6 +132,10 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
 int32_t gps_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
 
     GpsUart* gps_uart = gps_uart_enable();
@@ -139,6 +144,9 @@ int32_t gps_app(void* p) {
     if(!gps_uart->mutex) {
         FURI_LOG_E("GPS", "cannot create mutex\r\n");
         free(gps_uart);
+        // Return previous state of expansion
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -271,5 +279,9 @@ int32_t gps_app(void* p) {
         furi_hal_power_disable_otg();
     }
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 12 - 0
base_pack/hc_sr04/hc_sr04.c

@@ -11,6 +11,7 @@
 #include <gui/elements.h>
 #include <notification/notification.h>
 #include <notification/notification_messages.h>
+#include <expansion/expansion.h>
 
 typedef enum {
     EventTypeTick,
@@ -176,6 +177,10 @@ static void hc_sr04_measure(PluginState* const plugin_state) {
 }
 
 int32_t hc_sr04_app() {
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
 
     PluginState* plugin_state = malloc(sizeof(PluginState));
@@ -194,6 +199,9 @@ int32_t hc_sr04_app() {
         furi_hal_power_suppress_charge_exit();
         furi_message_queue_free(event_queue);
         free(plugin_state);
+        // Return previous state of expansion
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -270,5 +278,9 @@ int32_t hc_sr04_app() {
     furi_mutex_free(plugin_state->mutex);
     free(plugin_state);
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 12 - 0
base_pack/sentry_safe/sentry_safe.c

@@ -4,6 +4,7 @@
 #include <stdlib.h>
 
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 typedef struct {
     uint8_t status;
@@ -83,6 +84,10 @@ void try_code(int a, int b, int c, int d, int e) {
 int32_t sentry_safe_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(Event));
 
     SentryState* sentry_state = malloc(sizeof(SentryState));
@@ -94,6 +99,9 @@ int32_t sentry_safe_app(void* p) {
         FURI_LOG_E("SentrySafe", "cannot create mutex\r\n");
         furi_message_queue_free(event_queue);
         free(sentry_state);
+        // Return previous state of expansion
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -165,5 +173,9 @@ int32_t sentry_safe_app(void* p) {
     furi_mutex_free(sentry_state->mutex);
     free(sentry_state);
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 9 - 0
base_pack/uart_terminal/uart_terminal_app.c

@@ -2,6 +2,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool uart_terminal_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -117,6 +118,10 @@ void uart_terminal_app_free(UART_TerminalApp* app) {
 
 int32_t uart_terminal_app(void* p) {
     UNUSED(p);
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     UART_TerminalApp* uart_terminal_app = uart_terminal_app_alloc();
 
     uart_terminal_app->uart = uart_terminal_uart_init(uart_terminal_app);
@@ -125,5 +130,9 @@ int32_t uart_terminal_app(void* p) {
 
     uart_terminal_app_free(uart_terminal_app);
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 8 - 0
base_pack/wifi_marauder_companion/wifi_marauder_app.c

@@ -2,6 +2,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool wifi_marauder_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -172,6 +173,9 @@ void wifi_marauder_app_free(WifiMarauderApp* app) {
 
 int32_t wifi_marauder_app(void* p) {
     UNUSED(p);
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
 
     uint8_t attempts = 0;
     bool otg_was_enabled = furi_hal_power_is_otg_enabled();
@@ -196,5 +200,9 @@ int32_t wifi_marauder_app(void* p) {
         furi_hal_power_disable_otg();
     }
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 12 - 0
base_pack/wifi_scanner/wifi_scanner.c

@@ -10,6 +10,7 @@
 #include <notification/notification.h>
 #include <notification/notification_messages.h>
 #include <stdlib.h>
+#include <expansion/expansion.h>
 
 #include "FlipperZeroWiFiModuleDefines.h"
 
@@ -838,6 +839,10 @@ void send_serial_command(SWiFiScannerApp* app, ESerialCommand command) {
 int32_t wifi_scanner_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     WIFI_APP_LOG_I("Init");
 
     // FuriTimer* timer = furi_timer_alloc(blink_test_update, FuriTimerTypePeriodic, event_queue);
@@ -874,6 +879,9 @@ int32_t wifi_scanner_app(void* p) {
     if(!app->mutex) {
         WIFI_APP_LOG_E("cannot create mutex\r\n");
         free(app);
+        // Return previous state of expansion
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -1061,5 +1069,9 @@ int32_t wifi_scanner_app(void* p) {
     }
 #endif
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 10 - 0
non_catalog_apps/LORA_term/uart_terminal_app.c

@@ -2,6 +2,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool uart_terminal_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -92,6 +93,11 @@ void uart_terminal_app_free(UART_TerminalApp* app) {
 
 int32_t uart_terminal_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     UART_TerminalApp* uart_terminal_app = uart_terminal_app_alloc();
 
     uart_terminal_app->uart = uart_terminal_uart_init(uart_terminal_app);
@@ -100,5 +106,9 @@ int32_t uart_terminal_app(void* p) {
 
     uart_terminal_app_free(uart_terminal_app);
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 11 - 0
non_catalog_apps/bc_scanner_emulator/bc_scanner_app.c

@@ -3,6 +3,8 @@
 #include <furi_hal.h>
 #include <storage/storage.h>
 #include <lib/toolbox/path.h>
+#include <expansion/expansion.h>
+
 #define TAG "BarCodeScanner"
 #define WORKER_TAG TAG "App"
 
@@ -106,10 +108,19 @@ void bc_scanner_app_free(BarCodeApp* app) {
 
 int32_t bc_scanner_app(void* p) {
     FURI_LOG_D(WORKER_TAG, "Start App");
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     BarCodeApp* bar_code_app = bc_scanner_app_alloc((char*)p);
 
     view_dispatcher_run(bar_code_app->view_dispatcher);
 
     bc_scanner_app_free(bar_code_app);
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 9 - 0
non_catalog_apps/esp32_gravity/uart_terminal_app.c

@@ -2,6 +2,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool uart_terminal_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -92,6 +93,10 @@ void uart_terminal_app_free(UART_TerminalApp* app) {
 
 int32_t uart_terminal_app(void* p) {
     UNUSED(p);
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     UART_TerminalApp* uart_terminal_app = uart_terminal_app_alloc();
 
     uart_terminal_app->uart = uart_terminal_uart_init(uart_terminal_app);
@@ -100,5 +105,9 @@ int32_t uart_terminal_app(void* p) {
 
     uart_terminal_app_free(uart_terminal_app);
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 9 - 0
non_catalog_apps/esp_flasher/esp_flasher_app.c

@@ -2,6 +2,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool esp_flasher_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -118,6 +119,10 @@ void esp_flasher_app_free(EspFlasherApp* app) {
 int32_t esp_flasher_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     uint8_t attempts = 0;
     bool otg_was_enabled = furi_hal_power_is_otg_enabled();
     while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
@@ -140,5 +145,9 @@ int32_t esp_flasher_app(void* p) {
         furi_hal_power_disable_otg();
     }
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 11 - 0
non_catalog_apps/flipagotchi/src/flipagotchi.c

@@ -6,6 +6,7 @@
 #include <furi_hal.h>
 #include <gui/view_dispatcher.h>
 #include <gui/modules/dialog_ex.h>
+#include <expansion/expansion.h>
 
 #include "../include/pwnagotchi.h"
 #include "../include/protocol.h"
@@ -348,8 +349,18 @@ static void flipagotchi_app_free(FlipagotchiApp* app) {
 
 int32_t flipagotchi_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     FlipagotchiApp* app = flipagotchi_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     flipagotchi_app_free(app);
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 10 - 0
non_catalog_apps/flipper_evil_portal/evil_portal_app.c

@@ -3,6 +3,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool evil_portal_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -127,6 +128,11 @@ void evil_portal_app_free(Evil_PortalApp* app) {
 
 int32_t evil_portal_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     Evil_PortalApp* evil_portal_app = evil_portal_app_alloc();
 
     bool otg_was_enabled = furi_hal_power_is_otg_enabled();
@@ -151,5 +157,9 @@ int32_t evil_portal_app(void* p) {
         furi_hal_power_disable_otg();
     }
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 11 - 0
non_catalog_apps/flipperzero-camera/camera.c

@@ -1,4 +1,5 @@
 #include "camera.h"
+#include <expansion/expansion.h>
 
 static void camera_view_draw_callback(Canvas* canvas, void* _model) {
     UartDumpModel* model = _model;
@@ -287,8 +288,18 @@ static void camera_app_free(UartEchoApp* app) {
 
 int32_t camera_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     UartEchoApp* app = camera_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     camera_app_free(app);
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 10 - 0
non_catalog_apps/flipperzero_gpioreader/gpio_app.c

@@ -2,6 +2,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool gpio_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -101,11 +102,20 @@ void gpio_app_free(GpioApp* app) {
 
 int32_t gpio_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     GpioApp* gpio_app = gpio_app_alloc();
 
     view_dispatcher_run(gpio_app->view_dispatcher);
 
     gpio_app_free(gpio_app);
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 10 - 0
non_catalog_apps/ifttt/ifttt_virtual_button.c

@@ -1,4 +1,5 @@
 #include "ifttt_virtual_button.h"
+#include <expansion/expansion.h>
 
 #define IFTTT_FOLDER "/ext/apps_data/ifttt"
 #define IFTTT_CONFIG_FOLDER "/ext/apps_data/ifttt/config"
@@ -227,6 +228,10 @@ void ifttt_virtual_button_app_free(VirtualButtonApp* app) {
 
 int32_t ifttt_virtual_button_app(void* p) {
     UNUSED(p);
+    
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
 
     Storage* storage = furi_record_open(RECORD_STORAGE);
     if(!storage_simply_mkdir(storage, IFTTT_FOLDER)) {
@@ -242,5 +247,10 @@ int32_t ifttt_virtual_button_app(void* p) {
 
     view_dispatcher_run(app->view_dispatcher);
     ifttt_virtual_button_app_free(app);
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 11 - 1
non_catalog_apps/magspoof_flipper/mag.c

@@ -1,4 +1,5 @@
 #include "mag_i.h"
+#include <expansion/expansion.h>
 
 #define TAG "Mag"
 
@@ -174,8 +175,13 @@ static void mag_free(Mag* mag) {
 
 // entry point for app
 int32_t mag_app(void* p) {
-    Mag* mag = mag_alloc();
     UNUSED(p);
+    
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
+    Mag* mag = mag_alloc();
 
     mag_make_app_folder(mag);
 
@@ -199,6 +205,10 @@ int32_t mag_app(void* p) {
 
     mag_free(mag);
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }
 

+ 10 - 0
non_catalog_apps/seader/seader.c

@@ -1,4 +1,5 @@
 #include "seader_i.h"
+#include <expansion/expansion.h>
 
 #define TAG "Seader"
 
@@ -194,6 +195,11 @@ void seader_show_loading_popup(void* context, bool show) {
 
 int32_t seader_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     Seader* seader = seader_alloc();
 
     scene_manager_next_scene(seader->scene_manager, SeaderSceneStart);
@@ -202,5 +208,9 @@ int32_t seader_app(void* p) {
 
     seader_free(seader);
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 11 - 0
non_catalog_apps/uhf_rfid/uhf_app.c

@@ -1,4 +1,5 @@
 #include "uhf_app_i.h"
+#include <expansion/expansion.h>
 
 char* convertToHexString(uint8_t* array, size_t length) {
     if(array == NULL || length == 0) {
@@ -194,6 +195,11 @@ void uhf_show_loading_popup(void* ctx, bool show) {
 
 int32_t uhf_app_main(void* ctx) {
     UNUSED(ctx);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     UHFApp* uhf_app = uhf_alloc();
 
     // enable 5v pin
@@ -216,5 +222,10 @@ int32_t uhf_app_main(void* ctx) {
     // furi_hal_gpio_disable_int_callback()
     // exit app
     uhf_free(uhf_app);
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 12 - 0
non_catalog_apps/usping/usping.c

@@ -13,6 +13,7 @@
 #include <gui/elements.h>
 #include <notification/notification.h>
 #include <notification/notification_messages.h>
+#include <expansion/expansion.h>
 
 typedef enum {
     EventTypeTick,
@@ -178,6 +179,10 @@ static void usping_measure(PluginState* const plugin_state) {
 }
 
 int32_t usping_app() {
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
 
     PluginState* plugin_state = malloc(sizeof(PluginState));
@@ -196,6 +201,9 @@ int32_t usping_app() {
         furi_hal_power_suppress_charge_exit();
         furi_message_queue_free(event_queue);
         free(plugin_state);
+        // Return previous state of expansion
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -266,6 +274,10 @@ int32_t usping_app() {
     furi_message_queue_free(event_queue);
     furi_mutex_free(plugin_state->mutex);
     free(plugin_state);
+    
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
 
     return 0;
 }

+ 10 - 0
non_catalog_apps/wifi-map/wifi_map.c

@@ -11,6 +11,7 @@
 #include <gui/elements.h>
 #include <gui/view_dispatcher.h>
 #include <gui/modules/dialog_ex.h>
+#include <expansion/expansion.h>
 
 #define LINES_ON_SCREEN 6
 #define COLUMNS_ON_SCREEN 21
@@ -306,9 +307,18 @@ static void uart_echo_app_free(WiFiMapApp* app) {
 
 int32_t wifi_map_app(void* p) {
     UNUSED(p);
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+    
     FURI_LOG_D(TAG, "wifi_map_app");
     WiFiMapApp* app = uart_echo_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     uart_echo_app_free(app);
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 22 - 3
non_catalog_apps/wifi_deauther/wifi_deauther_app.c

@@ -3,6 +3,7 @@
 #include <furi_hal_power.h>
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool wifi_deauther_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -90,9 +91,20 @@ void wifi_deauther_app_free(WifideautherApp* app) {
 }
 
 int32_t wifi_deauther_app(void* p) {
-    furi_hal_power_enable_otg();
-    furi_delay_ms(600);
     UNUSED(p);
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
+    // Enable 5v power, multiple attempts to avoid issues with power chip protection false triggering
+    uint8_t attempts = 0;
+    bool otg_was_enabled = furi_hal_power_is_otg_enabled();
+    while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
+        furi_hal_power_enable_otg();
+        furi_delay_ms(10);
+    }
+    furi_delay_ms(600);
+
     WifideautherApp* wifi_deauther_app = wifi_deauther_app_alloc();
 
     wifi_deauther_app->uart = wifi_deauther_uart_init(wifi_deauther_app);
@@ -100,7 +112,14 @@ int32_t wifi_deauther_app(void* p) {
     view_dispatcher_run(wifi_deauther_app->view_dispatcher);
 
     wifi_deauther_app_free(wifi_deauther_app);
-    furi_hal_power_disable_otg();
+    
+    if(furi_hal_power_is_otg_enabled() && !otg_was_enabled) {
+        furi_hal_power_disable_otg();
+    }
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
 
     return 0;
 }