From 0875b3c485f5fbf2aade2425fce551238a458c1f Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:01:14 +0300 Subject: [PATCH] fix uart related plugins to disable expansion protocol --- apps_source_code/airmon/airmon.c | 13 ++++++++++ base_pack/camera_suite/camera_suite.c | 11 ++++++++ base_pack/dap_link/dap_link.c | 12 +++++++++ base_pack/esp8266_deauth/esp8266_deauth.c | 12 +++++++++ base_pack/gps_nmea_uart/gps.c | 12 +++++++++ base_pack/hc_sr04/hc_sr04.c | 12 +++++++++ base_pack/sentry_safe/sentry_safe.c | 12 +++++++++ base_pack/uart_terminal/uart_terminal_app.c | 9 +++++++ .../wifi_marauder_app.c | 8 ++++++ base_pack/wifi_scanner/wifi_scanner.c | 12 +++++++++ .../LORA_term/uart_terminal_app.c | 10 ++++++++ .../bc_scanner_emulator/bc_scanner_app.c | 11 ++++++++ .../esp32_gravity/uart_terminal_app.c | 9 +++++++ .../esp_flasher/esp_flasher_app.c | 9 +++++++ .../flipagotchi/src/flipagotchi.c | 11 ++++++++ .../flipper_evil_portal/evil_portal_app.c | 10 ++++++++ non_catalog_apps/flipperzero-camera/camera.c | 11 ++++++++ .../flipperzero_gpioreader/gpio_app.c | 10 ++++++++ non_catalog_apps/ifttt/ifttt_virtual_button.c | 10 ++++++++ non_catalog_apps/magspoof_flipper/mag.c | 12 ++++++++- non_catalog_apps/seader/seader.c | 10 ++++++++ non_catalog_apps/uhf_rfid/uhf_app.c | 11 ++++++++ non_catalog_apps/usping/usping.c | 12 +++++++++ non_catalog_apps/wifi-map/wifi_map.c | 10 ++++++++ .../wifi_deauther/wifi_deauther_app.c | 25 ++++++++++++++++--- 25 files changed, 280 insertions(+), 4 deletions(-) diff --git a/apps_source_code/airmon/airmon.c b/apps_source_code/airmon/airmon.c index 202f0e2c597..8615506dda2 100644 --- a/apps_source_code/airmon/airmon.c +++ b/apps_source_code/airmon/airmon.c @@ -5,6 +5,8 @@ #include #include +#include + #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; } \ No newline at end of file diff --git a/base_pack/camera_suite/camera_suite.c b/base_pack/camera_suite/camera_suite.c index 04c034b153d..a78d8d27bba 100644 --- a/base_pack/camera_suite/camera_suite.c +++ b/base_pack/camera_suite/camera_suite.c @@ -1,5 +1,6 @@ #include "camera_suite.h" #include +#include 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; } diff --git a/base_pack/dap_link/dap_link.c b/base_pack/dap_link/dap_link.c index b20100cccf4..94975c7494a 100644 --- a/base_pack/dap_link/dap_link.c +++ b/base_pack/dap_link/dap_link.c @@ -9,6 +9,8 @@ #include #include +#include + #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; } \ No newline at end of file diff --git a/base_pack/esp8266_deauth/esp8266_deauth.c b/base_pack/esp8266_deauth/esp8266_deauth.c index 48b9a79d858..d5d00b65610 100644 --- a/base_pack/esp8266_deauth/esp8266_deauth.c +++ b/base_pack/esp8266_deauth/esp8266_deauth.c @@ -6,6 +6,7 @@ #include #include #include +#include //#include //#include //#include @@ -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; } diff --git a/base_pack/gps_nmea_uart/gps.c b/base_pack/gps_nmea_uart/gps.c index 8327e4746c4..0c17412962e 100644 --- a/base_pack/gps_nmea_uart/gps.c +++ b/base_pack/gps_nmea_uart/gps.c @@ -4,6 +4,7 @@ #include #include #include +#include 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; } diff --git a/base_pack/hc_sr04/hc_sr04.c b/base_pack/hc_sr04/hc_sr04.c index e8372106cef..5cdeac3f7d3 100644 --- a/base_pack/hc_sr04/hc_sr04.c +++ b/base_pack/hc_sr04/hc_sr04.c @@ -11,6 +11,7 @@ #include #include #include +#include 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; } diff --git a/base_pack/sentry_safe/sentry_safe.c b/base_pack/sentry_safe/sentry_safe.c index f8f8db6c6e3..b208b7629ea 100644 --- a/base_pack/sentry_safe/sentry_safe.c +++ b/base_pack/sentry_safe/sentry_safe.c @@ -4,6 +4,7 @@ #include #include +#include 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; } \ No newline at end of file diff --git a/base_pack/uart_terminal/uart_terminal_app.c b/base_pack/uart_terminal/uart_terminal_app.c index f3a88468ce6..d0e59d3fea9 100644 --- a/base_pack/uart_terminal/uart_terminal_app.c +++ b/base_pack/uart_terminal/uart_terminal_app.c @@ -2,6 +2,7 @@ #include #include +#include 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; } diff --git a/base_pack/wifi_marauder_companion/wifi_marauder_app.c b/base_pack/wifi_marauder_companion/wifi_marauder_app.c index 2f88cad1a99..71137e1fc3b 100644 --- a/base_pack/wifi_marauder_companion/wifi_marauder_app.c +++ b/base_pack/wifi_marauder_companion/wifi_marauder_app.c @@ -2,6 +2,7 @@ #include #include +#include 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; } diff --git a/base_pack/wifi_scanner/wifi_scanner.c b/base_pack/wifi_scanner/wifi_scanner.c index 8658614dd14..07146c2045d 100644 --- a/base_pack/wifi_scanner/wifi_scanner.c +++ b/base_pack/wifi_scanner/wifi_scanner.c @@ -10,6 +10,7 @@ #include #include #include +#include #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; } \ No newline at end of file diff --git a/non_catalog_apps/LORA_term/uart_terminal_app.c b/non_catalog_apps/LORA_term/uart_terminal_app.c index 2c18c5baee3..625d2d5f602 100644 --- a/non_catalog_apps/LORA_term/uart_terminal_app.c +++ b/non_catalog_apps/LORA_term/uart_terminal_app.c @@ -2,6 +2,7 @@ #include #include +#include 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; } diff --git a/non_catalog_apps/bc_scanner_emulator/bc_scanner_app.c b/non_catalog_apps/bc_scanner_emulator/bc_scanner_app.c index 62839050466..a88b844cd1d 100644 --- a/non_catalog_apps/bc_scanner_emulator/bc_scanner_app.c +++ b/non_catalog_apps/bc_scanner_emulator/bc_scanner_app.c @@ -3,6 +3,8 @@ #include #include #include +#include + #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; } diff --git a/non_catalog_apps/esp32_gravity/uart_terminal_app.c b/non_catalog_apps/esp32_gravity/uart_terminal_app.c index 2c18c5baee3..8c57d6d77aa 100644 --- a/non_catalog_apps/esp32_gravity/uart_terminal_app.c +++ b/non_catalog_apps/esp32_gravity/uart_terminal_app.c @@ -2,6 +2,7 @@ #include #include +#include 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; } diff --git a/non_catalog_apps/esp_flasher/esp_flasher_app.c b/non_catalog_apps/esp_flasher/esp_flasher_app.c index a6c85323ca2..cf6d1e596eb 100644 --- a/non_catalog_apps/esp_flasher/esp_flasher_app.c +++ b/non_catalog_apps/esp_flasher/esp_flasher_app.c @@ -2,6 +2,7 @@ #include #include +#include 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; } diff --git a/non_catalog_apps/flipagotchi/src/flipagotchi.c b/non_catalog_apps/flipagotchi/src/flipagotchi.c index 1c9fdfaad97..cf259d1408b 100644 --- a/non_catalog_apps/flipagotchi/src/flipagotchi.c +++ b/non_catalog_apps/flipagotchi/src/flipagotchi.c @@ -6,6 +6,7 @@ #include #include #include +#include #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; } \ No newline at end of file diff --git a/non_catalog_apps/flipper_evil_portal/evil_portal_app.c b/non_catalog_apps/flipper_evil_portal/evil_portal_app.c index b679b03418a..6efb4e9e44c 100644 --- a/non_catalog_apps/flipper_evil_portal/evil_portal_app.c +++ b/non_catalog_apps/flipper_evil_portal/evil_portal_app.c @@ -3,6 +3,7 @@ #include #include +#include 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; } diff --git a/non_catalog_apps/flipperzero-camera/camera.c b/non_catalog_apps/flipperzero-camera/camera.c index 10fd640b252..e50eec873b5 100644 --- a/non_catalog_apps/flipperzero-camera/camera.c +++ b/non_catalog_apps/flipperzero-camera/camera.c @@ -1,4 +1,5 @@ #include "camera.h" +#include 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; } diff --git a/non_catalog_apps/flipperzero_gpioreader/gpio_app.c b/non_catalog_apps/flipperzero_gpioreader/gpio_app.c index 07a79cb8928..d04aaaa6712 100644 --- a/non_catalog_apps/flipperzero_gpioreader/gpio_app.c +++ b/non_catalog_apps/flipperzero_gpioreader/gpio_app.c @@ -2,6 +2,7 @@ #include #include +#include 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; } diff --git a/non_catalog_apps/ifttt/ifttt_virtual_button.c b/non_catalog_apps/ifttt/ifttt_virtual_button.c index 0954e5ed955..d8252f44ebd 100644 --- a/non_catalog_apps/ifttt/ifttt_virtual_button.c +++ b/non_catalog_apps/ifttt/ifttt_virtual_button.c @@ -1,4 +1,5 @@ #include "ifttt_virtual_button.h" +#include #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; } diff --git a/non_catalog_apps/magspoof_flipper/mag.c b/non_catalog_apps/magspoof_flipper/mag.c index 329f698ce06..a216f16e675 100644 --- a/non_catalog_apps/magspoof_flipper/mag.c +++ b/non_catalog_apps/magspoof_flipper/mag.c @@ -1,4 +1,5 @@ #include "mag_i.h" +#include #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; } diff --git a/non_catalog_apps/seader/seader.c b/non_catalog_apps/seader/seader.c index 04d7ff59b27..d9d880a9d2f 100644 --- a/non_catalog_apps/seader/seader.c +++ b/non_catalog_apps/seader/seader.c @@ -1,4 +1,5 @@ #include "seader_i.h" +#include #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; } diff --git a/non_catalog_apps/uhf_rfid/uhf_app.c b/non_catalog_apps/uhf_rfid/uhf_app.c index 001ae2978dc..ff52882df8d 100644 --- a/non_catalog_apps/uhf_rfid/uhf_app.c +++ b/non_catalog_apps/uhf_rfid/uhf_app.c @@ -1,4 +1,5 @@ #include "uhf_app_i.h" +#include 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; } \ No newline at end of file diff --git a/non_catalog_apps/usping/usping.c b/non_catalog_apps/usping/usping.c index cc36a2bb224..adaf8d7de5f 100644 --- a/non_catalog_apps/usping/usping.c +++ b/non_catalog_apps/usping/usping.c @@ -13,6 +13,7 @@ #include #include #include +#include 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; } diff --git a/non_catalog_apps/wifi-map/wifi_map.c b/non_catalog_apps/wifi-map/wifi_map.c index 224427b60dd..d1db9a8e099 100644 --- a/non_catalog_apps/wifi-map/wifi_map.c +++ b/non_catalog_apps/wifi-map/wifi_map.c @@ -11,6 +11,7 @@ #include #include #include +#include #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; } diff --git a/non_catalog_apps/wifi_deauther/wifi_deauther_app.c b/non_catalog_apps/wifi_deauther/wifi_deauther_app.c index 28fb28d8850..b7088341165 100644 --- a/non_catalog_apps/wifi_deauther/wifi_deauther_app.c +++ b/non_catalog_apps/wifi_deauther/wifi_deauther_app.c @@ -3,6 +3,7 @@ #include #include #include +#include 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; }