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

wipe logs once saved. don't log reset output.

bigbrodude6119 2 лет назад
Родитель
Сommit
cd4f624264
4 измененных файлов с 21 добавлено и 11 удалено
  1. 3 1
      evil_portal_app.c
  2. 1 0
      evil_portal_app_i.h
  3. 8 4
      evil_portal_uart.c
  4. 9 6
      scenes/evil_portal_scene_console_output.c

+ 3 - 1
evil_portal_app.c

@@ -28,7 +28,8 @@ Evil_PortalApp *evil_portal_app_alloc() {
 
 
   app->sent_html = false;
   app->sent_html = false;
   app->sent_ap = false;
   app->sent_ap = false;
-  app->has_command_queue = false;
+  app->sent_reset = false;
+  app->has_command_queue = false;  
   app->command_index = 0;
   app->command_index = 0;
   app->portal_logs = malloc(5000);
   app->portal_logs = malloc(5000);
 
 
@@ -74,6 +75,7 @@ void evil_portal_app_free(Evil_PortalApp *app) {
   // save latest logs
   // save latest logs
   if (strlen(app->portal_logs) > 0) {
   if (strlen(app->portal_logs) > 0) {
     write_logs(app->portal_logs);
     write_logs(app->portal_logs);
+    free(app->portal_logs);
   }
   }
 
 
   // Send reset event to dev board
   // Send reset event to dev board

+ 1 - 0
evil_portal_app_i.h

@@ -46,6 +46,7 @@ struct Evil_PortalApp {
   bool show_stopscan_tip;
   bool show_stopscan_tip;
   bool sent_ap;
   bool sent_ap;
   bool sent_html;
   bool sent_html;
+  bool sent_reset;
   int BAUDRATE;
   int BAUDRATE;
 
 
   uint8_t *index_html;
   uint8_t *index_html;

+ 8 - 4
evil_portal_uart.c

@@ -51,12 +51,12 @@ static int32_t uart_worker(void *context) {
         if (uart->handle_rx_data_cb) {
         if (uart->handle_rx_data_cb) {
           uart->handle_rx_data_cb(uart->rx_buf, len, uart->app);
           uart->handle_rx_data_cb(uart->rx_buf, len, uart->app);
 
 
-          if (uart->app->has_command_queue) {         
-            if (uart->app->command_index < 1) {            
+          if (uart->app->has_command_queue) {
+            if (uart->app->command_index < 1) {
               if (0 ==
               if (0 ==
                   strncmp(SET_AP_CMD,
                   strncmp(SET_AP_CMD,
                           uart->app->command_queue[uart->app->command_index],
                           uart->app->command_queue[uart->app->command_index],
-                          strlen(SET_AP_CMD))) {                
+                          strlen(SET_AP_CMD))) {
                 char *out_data =
                 char *out_data =
                     malloc((size_t)(strlen((char *)uart->app->ap_name) +
                     malloc((size_t)(strlen((char *)uart->app->ap_name) +
                                     strlen("setap=")));
                                     strlen("setap=")));
@@ -78,10 +78,14 @@ static int32_t uart_worker(void *context) {
             }
             }
           }
           }
 
 
-          strcat(uart->app->portal_logs, (char *)uart->rx_buf);
+          if (uart->app->sent_reset == false) {
+            strcat(uart->app->portal_logs, (char *)uart->rx_buf);
+          }
+
           if (strlen(uart->app->portal_logs) > 4000) {
           if (strlen(uart->app->portal_logs) > 4000) {
             write_logs(uart->app->portal_logs);
             write_logs(uart->app->portal_logs);
             free(uart->app->portal_logs);
             free(uart->app->portal_logs);
+            strcpy(uart->app->portal_logs, "");
           }
           }
         }
         }
       }
       }

+ 9 - 6
scenes/evil_portal_scene_console_output.c

@@ -36,6 +36,7 @@ void evil_portal_scene_console_output_on_enter(void *context) {
   if (app->is_command) {
   if (app->is_command) {
     furi_string_reset(app->text_box_store);
     furi_string_reset(app->text_box_store);
     app->text_box_store_strlen = 0;
     app->text_box_store_strlen = 0;
+    app->sent_reset = false;
 
 
     if (0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
     if (0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
       const char *help_msg =
       const char *help_msg =
@@ -54,10 +55,9 @@ void evil_portal_scene_console_output_on_enter(void *context) {
       const char *help_msg = "Logs saved.\n\n";
       const char *help_msg = "Logs saved.\n\n";
       furi_string_cat_str(app->text_box_store, help_msg);
       furi_string_cat_str(app->text_box_store, help_msg);
       app->text_box_store_strlen += strlen(help_msg);
       app->text_box_store_strlen += strlen(help_msg);
-      if(strlen(app->portal_logs) > 0) {
-        write_logs(app->portal_logs);
-        free(app->portal_logs);
-      }      
+      write_logs(app->portal_logs);
+      free(app->portal_logs);
+      strcpy(app->portal_logs, "");
       if (app->show_stopscan_tip) {
       if (app->show_stopscan_tip) {
         const char *msg = "Press BACK to return\n";
         const char *msg = "Press BACK to return\n";
         furi_string_cat_str(app->text_box_store, msg);
         furi_string_cat_str(app->text_box_store, msg);
@@ -65,7 +65,8 @@ void evil_portal_scene_console_output_on_enter(void *context) {
       }
       }
     }
     }
 
 
-    if (0 == strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
+    if (0 ==
+        strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
       app->command_queue[0] = SET_AP_CMD;
       app->command_queue[0] = SET_AP_CMD;
       app->has_command_queue = true;
       app->has_command_queue = true;
       app->command_index = 0;
       app->command_index = 0;
@@ -78,6 +79,7 @@ void evil_portal_scene_console_output_on_enter(void *context) {
     }
     }
 
 
     if (0 == strncmp(RESET_CMD, app->selected_tx_string, strlen(RESET_CMD))) {
     if (0 == strncmp(RESET_CMD, app->selected_tx_string, strlen(RESET_CMD))) {
+      app->sent_reset = true;
       if (app->show_stopscan_tip) {
       if (app->show_stopscan_tip) {
         const char *msg = "Reseting portal\nPress BACK to return\n\n\n\n";
         const char *msg = "Reseting portal\nPress BACK to return\n\n\n\n";
         furi_string_cat_str(app->text_box_store, msg);
         furi_string_cat_str(app->text_box_store, msg);
@@ -98,7 +100,8 @@ void evil_portal_scene_console_output_on_enter(void *context) {
       app->uart, evil_portal_console_output_handle_rx_data_cb);
       app->uart, evil_portal_console_output_handle_rx_data_cb);
 
 
   if (app->is_command && app->selected_tx_string) {
   if (app->is_command && app->selected_tx_string) {
-    if (0 == strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
+    if (0 ==
+        strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
       evil_portal_read_index_html(context);
       evil_portal_read_index_html(context);
 
 
       char *data = malloc(
       char *data = malloc(