Просмотр исходного кода

WifiDeauther: Gpio and manifest changes

Willy-JL 2 лет назад
Родитель
Сommit
9aa22756b4

+ 1 - 1
wifi_deauther/application.fam

@@ -8,7 +8,7 @@ App(
     stack_size=1 * 1024,
     order=30,
     fap_icon="wifi_10px.png",
-    fap_category="GPIO",
+    fap_category="WiFi",
     fap_author="@Timmotools & @xMasterX",
     fap_weburl="https://github.com/Timmotools/flipperzero_esp8266_deautherv2",
     fap_version="1.0",

+ 5 - 0
wifi_deauther/wifi_deauther_app_i.h

@@ -12,6 +12,11 @@
 #include <gui/modules/text_input.h>
 #include <gui/modules/variable_item_list.h>
 
+#include <xtreme.h>
+
+#define UART_CH \
+    (xtreme_settings.uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : FuriHalUartIdLPUART1)
+
 #define NUM_MENU_ITEMS (11)
 
 #define WIFI_deauther_TEXT_BOX_STORE_SIZE (4096)

+ 12 - 4
wifi_deauther/wifi_deauther_uart.c

@@ -4,7 +4,6 @@
 #include <FreeRTOS.h>
 #include <stream_buffer.h>
 
-#define UART_CH (FuriHalUartIdUSART1)
 #define BAUDRATE (115200)
 
 struct WifideautherUart {
@@ -55,6 +54,7 @@ static int32_t uart_worker(void* context) {
         }
     }
 
+    furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL);
     furi_stream_buffer_free(uart->rx_stream);
 
     return 0;
@@ -77,7 +77,12 @@ WifideautherUart* wifi_deauther_uart_init(WifideautherApp* app) {
 
     furi_thread_start(uart->rx_thread);
 
-    furi_hal_console_disable();
+    if(UART_CH == FuriHalUartIdUSART1) {
+        furi_hal_console_disable();
+    } else if(UART_CH == FuriHalUartIdLPUART1) {
+        furi_hal_uart_init(UART_CH, BAUDRATE);
+    }
+
     furi_hal_uart_set_br(UART_CH, BAUDRATE);
     furi_hal_uart_set_irq_cb(UART_CH, wifi_deauther_uart_on_irq_cb, uart);
 
@@ -91,8 +96,11 @@ void wifi_deauther_uart_free(WifideautherUart* uart) {
     furi_thread_join(uart->rx_thread);
     furi_thread_free(uart->rx_thread);
 
-    furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL);
-    furi_hal_console_enable();
+    if(UART_CH == FuriHalUartIdLPUART1) {
+        furi_hal_uart_deinit(UART_CH);
+    } else {
+        furi_hal_console_enable();
+    }
 
     free(uart);
 }