bigbrodude6119 2 лет назад
Родитель
Сommit
2b618e2813
3 измененных файлов с 47 добавлено и 73 удалено
  1. 0 1
      evil_portal_app_i.h
  2. 0 19
      evil_portal_uart.c
  3. 47 53
      scenes/evil_portal_scene_console_output.c

+ 0 - 1
evil_portal_app_i.h

@@ -43,7 +43,6 @@ struct Evil_PortalApp {
   bool sent_ap;
   bool sent_html;
   int BAUDRATE;
-  int TERMINAL_MODE; // 1=AT mode, 0=other mode
 
   uint8_t *index_html;
   uint8_t *ap_name;

+ 0 - 19
evil_portal_uart.c

@@ -2,9 +2,6 @@
 #include "evil_portal_uart.h"
 #include "helpers/evil_portal_storage.h"
 
-// #define UART_CH (FuriHalUartIdUSART1)
-// #define BAUDRATE (115200)
-
 struct Evil_PortalUart {
   Evil_PortalApp *app;
   FuriThread *rx_thread;
@@ -82,24 +79,8 @@ static int32_t uart_worker(void *context) {
               uart->app->has_command_queue = false;
               uart->app->command_queue[0] = "";
             }
-
-            // if(0 == strncmp("ack", (char *)uart->rx_buf, strlen("ack"))) {
-
-            //   } else {
-            //     uart->app->command_index = 0;
-            //     uart->app->has_command_queue = false;
-            //     uart->app->command_queue[0] = "";
-            //   }
-            // }
           }
 
-          // rx_buf has response
-          // wait for ack
-          // if response is ack
-          // check for commands
-          // if has commands
-          // send next command
-
           strcat(uart->app->portal_logs, (char *)uart->rx_buf);
           if (strlen(uart->app->portal_logs) > 4000) {
             write_logs(uart->app->portal_logs);

+ 47 - 53
scenes/evil_portal_scene_console_output.c

@@ -102,63 +102,57 @@ void evil_portal_scene_console_output_on_enter(void *context) {
   // Send command with CR+LF or newline '\n'
   // it is sent here
   if (app->is_command && app->selected_tx_string) {
-    if (app->TERMINAL_MODE == 1) {
+
+    // handle special commands here
+    if (0 == strncmp("sethtml", app->selected_tx_string, strlen("sethtml"))) {
+      evil_portal_read_index_html(context);
+
+      char *data = malloc(
+          (size_t)(strlen((char *)app->index_html) + strlen("sethtml=")));
+      strcat(data, "sethtml=");
+      strcat(data, (char *)app->index_html);
+
+      evil_portal_uart_tx((uint8_t *)(data), strlen(data));
+      evil_portal_uart_tx((uint8_t *)("\n"), 1);
+
+      app->sent_html = true;
+
+      free(data);
+      free(app->index_html);
+
+      evil_portal_read_ap_name(context);
+    } else if (0 ==
+               strncmp("setap", app->selected_tx_string, strlen("setap"))) {
+
+      evil_portal_read_ap_name(context);
+
+      char *data =
+          malloc((size_t)(strlen((char *)app->ap_name) + strlen("setap=")));
+      strcat(data, "setap=");
+      strcat(data, (char *)app->ap_name);
+
+      evil_portal_uart_tx((uint8_t *)(data), strlen(data));
+      evil_portal_uart_tx((uint8_t *)("\n"), 1);
+
+      app->sent_ap = true;
+
+      free(data);
+      free(app->ap_name);
+    } else if (0 ==
+               strncmp("reset", app->selected_tx_string, strlen("reset"))) {
+      app->sent_html = false;
+      app->sent_ap = false;
       evil_portal_uart_tx((uint8_t *)(app->selected_tx_string),
                           strlen(app->selected_tx_string));
-      evil_portal_uart_tx((uint8_t *)("\r\n"), 2);
+      evil_portal_uart_tx((uint8_t *)("\n"), 1);
+    } else if (0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
+      // nothing to do
     } else {
-      // handle special commands here
-      if (0 == strncmp("sethtml", app->selected_tx_string, strlen("sethtml"))) {
-        evil_portal_read_index_html(context);
-
-        char *data = malloc(
-            (size_t)(strlen((char *)app->index_html) + strlen("sethtml=")));
-        strcat(data, "sethtml=");
-        strcat(data, (char *)app->index_html);
-
-        evil_portal_uart_tx((uint8_t *)(data), strlen(data));
-        evil_portal_uart_tx((uint8_t *)("\n"), 1);
-
-        app->sent_html = true;
-
-        free(data);
-        free(app->index_html);
-
-        evil_portal_read_ap_name(context);
-      } else if (0 ==
-                 strncmp("setap", app->selected_tx_string, strlen("setap"))) {
-
-        evil_portal_read_ap_name(context);
-
-        char *data =
-            malloc((size_t)(strlen((char *)app->ap_name) + strlen("setap=")));
-        strcat(data, "setap=");
-        strcat(data, (char *)app->ap_name);
-
-        evil_portal_uart_tx((uint8_t *)(data), strlen(data));
-        evil_portal_uart_tx((uint8_t *)("\n"), 1);
-
-        app->sent_ap = true;
-
-        free(data);
-        free(app->ap_name);
-      } else if (0 ==
-                 strncmp("reset", app->selected_tx_string, strlen("reset"))) {
-        app->sent_html = false;
-        app->sent_ap = false;
-        evil_portal_uart_tx((uint8_t *)(app->selected_tx_string),
-                            strlen(app->selected_tx_string));
-        evil_portal_uart_tx((uint8_t *)("\n"), 1);
-      } else if (0 ==
-                 strncmp("help", app->selected_tx_string, strlen("help"))) {
-        // do nothing?
-      } else {
-        evil_portal_uart_tx((uint8_t *)(app->selected_tx_string),
-                            strlen(app->selected_tx_string));
-        evil_portal_uart_tx((uint8_t *)("\n"), 1);
-      }
+      evil_portal_uart_tx((uint8_t *)(app->selected_tx_string),
+                          strlen(app->selected_tx_string));
+      evil_portal_uart_tx((uint8_t *)("\n"), 1);
     }
-  }   
+  }
 }
 
 bool evil_portal_scene_console_output_on_event(void *context,