Przeglądaj źródła

WifiScanner: Gpio, manifest changes

Willy-JL 2 lat temu
rodzic
commit
0ff22e1648

+ 5 - 0
wifi_scanner/FlipperZeroWiFiModuleDefines.h

@@ -15,3 +15,8 @@
 #define FLIPPERZERO_SERIAL_BAUD 115200
 
 #define NA 0
+
+#include <xtreme.h>
+
+#define UART_CH \
+    (xtreme_settings.uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : FuriHalUartIdLPUART1)

+ 2 - 2
wifi_scanner/application.fam

@@ -1,13 +1,13 @@
 App(
     appid="wifi_scanner",
-    name="[WiFi] Scanner",
+    name="[ESP] WiFi Scanner",
     apptype=FlipperAppType.EXTERNAL,
     entry_point="wifi_scanner_app",
     requires=["gui"],
     stack_size=2 * 1024,
     order=110,
     fap_icon="wifi_10px.png",
-    fap_category="GPIO",
+    fap_category="WiFi",
     fap_author="@SequoiaSan & @xMasterX",
     fap_version="1.1",
     fap_description="WiFi scanner module interface, based on ESP8266",

+ 14 - 9
wifi_scanner/wifi_scanner.c

@@ -835,7 +835,7 @@ void send_serial_command(ESerialCommand command) {
         return;
     };
 
-    furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
+    furi_hal_uart_tx(UART_CH, data, 1);
 }
 
 int32_t wifi_scanner_app(void* p) {
@@ -905,11 +905,14 @@ int32_t wifi_scanner_app(void* p) {
     WIFI_APP_LOG_I("UART thread allocated");
 
     // Enable uart listener
-#if DISABLE_CONSOLE
-    furi_hal_console_disable();
-#endif
-    furi_hal_uart_set_br(FuriHalUartIdUSART1, FLIPPERZERO_SERIAL_BAUD);
-    furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, uart_on_irq_cb, app);
+    if(UART_CH == FuriHalUartIdUSART1) {
+        furi_hal_console_disable();
+    } else if(UART_CH == FuriHalUartIdLPUART1) {
+        furi_hal_uart_init(UART_CH, FLIPPERZERO_SERIAL_BAUD);
+    }
+
+    furi_hal_uart_set_br(UART_CH, FLIPPERZERO_SERIAL_BAUD);
+    furi_hal_uart_set_irq_cb(UART_CH, uart_on_irq_cb, app);
     WIFI_APP_LOG_I("UART Listener created");
 
     // Because we assume that module was on before we launched the app. We need to ensure that module will be in initial state on app start
@@ -1034,9 +1037,11 @@ int32_t wifi_scanner_app(void* p) {
     // Reset GPIO pins to default state
     furi_hal_gpio_init(&gpio_ext_pc0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
 
-#if DISABLE_CONSOLE
-    furi_hal_console_enable();
-#endif
+    if(UART_CH == FuriHalUartIdLPUART1) {
+        furi_hal_uart_deinit(UART_CH);
+    } else {
+        furi_hal_console_enable();
+    }
 
     view_port_enabled_set(view_port, false);