Kaynağa Gözat

Add View Log menu actions to see output of last command

0xchocolate 3 yıl önce
ebeveyn
işleme
6f72ac71a6

+ 11 - 8
applications/wifi_marauder_companion/scenes/wifi_marauder_scene_console_output.c

@@ -22,14 +22,19 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
     WifiMarauderApp* app = context;
     WifiMarauderApp* app = context;
 
 
     TextBox* text_box = app->text_box;
     TextBox* text_box = app->text_box;
+    text_box_reset(app->text_box);
     text_box_set_font(text_box, TextBoxFontText);
     text_box_set_font(text_box, TextBoxFontText);
     if (app->focus_console_start) {
     if (app->focus_console_start) {
         text_box_set_focus(text_box, TextBoxFocusStart);
         text_box_set_focus(text_box, TextBoxFocusStart);
     } else {
     } else {
         text_box_set_focus(text_box, TextBoxFocusEnd);
         text_box_set_focus(text_box, TextBoxFocusEnd);
     }
     }
-    string_reset(app->text_box_store);
-    app->text_box_store_strlen = 0;
+    if (app->is_command) {
+        string_reset(app->text_box_store);
+        app->text_box_store_strlen = 0;
+    } else { // "View Log" menu action
+        text_box_set_text(app->text_box, string_get_cstr(app->text_box_store));
+    }
 
 
     scene_manager_set_scene_state(app->scene_manager, WifiMarauderSceneConsoleOutput, 0);
     scene_manager_set_scene_state(app->scene_manager, WifiMarauderSceneConsoleOutput, 0);
     view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput);
     view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput);
@@ -38,7 +43,7 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
     wifi_marauder_uart_set_handle_rx_data_cb(app->uart, wifi_marauder_console_output_handle_rx_data_cb); // setup callback for rx thread
     wifi_marauder_uart_set_handle_rx_data_cb(app->uart, wifi_marauder_console_output_handle_rx_data_cb); // setup callback for rx thread
 
 
     // Send command with newline '\n'
     // Send command with newline '\n'
-    if (app->selected_tx_string) {
+    if (app->is_command && app->selected_tx_string) {
         wifi_marauder_uart_tx((uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string));
         wifi_marauder_uart_tx((uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string));
         wifi_marauder_uart_tx((uint8_t*)("\n"), 1);
         wifi_marauder_uart_tx((uint8_t*)("\n"), 1);
     }
     }
@@ -66,9 +71,7 @@ void wifi_marauder_scene_console_output_on_exit(void* context) {
     wifi_marauder_uart_set_handle_rx_data_cb(app->uart, NULL);
     wifi_marauder_uart_set_handle_rx_data_cb(app->uart, NULL);
 
 
     // Automatically stop the scan when exiting view
     // Automatically stop the scan when exiting view
-    wifi_marauder_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n"));
-
-    text_box_reset(app->text_box);
-    string_reset(app->text_box_store);
-    app->text_box_store_strlen = 0;
+    if (app->is_command) {
+        wifi_marauder_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n"));
+    }
 }
 }

+ 4 - 1
applications/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c

@@ -1,6 +1,6 @@
 #include "../wifi_marauder_app_i.h"
 #include "../wifi_marauder_app_i.h"
 
 
-#define NUM_MENU_ITEMS (27)
+#define NUM_MENU_ITEMS (29)
 
 
 // For each command, define whether additional arguments are needed
 // For each command, define whether additional arguments are needed
 // (enabling text input to fill them out), and whether the console
 // (enabling text input to fill them out), and whether the console
@@ -16,6 +16,8 @@ struct WifiMarauderItem {
 };
 };
 
 
 const struct WifiMarauderItem items[NUM_MENU_ITEMS] = {
 const struct WifiMarauderItem items[NUM_MENU_ITEMS] = {
+    { "View Log (start)", NO_ARGS, FOCUS_CONSOLE_START },
+    { "View Log (end)", NO_ARGS, FOCUS_CONSOLE_END },
     { "attack -t beacon -l", NO_ARGS, FOCUS_CONSOLE_END },
     { "attack -t beacon -l", NO_ARGS, FOCUS_CONSOLE_END },
     { "attack -t beacon -r", NO_ARGS, FOCUS_CONSOLE_END },
     { "attack -t beacon -r", NO_ARGS, FOCUS_CONSOLE_END },
     { "attack -t beacon -a", NO_ARGS, FOCUS_CONSOLE_END },
     { "attack -t beacon -a", NO_ARGS, FOCUS_CONSOLE_END },
@@ -49,6 +51,7 @@ static void wifi_marauder_scene_start_var_list_enter_callback(void* context, uin
     furi_assert(context);
     furi_assert(context);
     WifiMarauderApp* app = context;
     WifiMarauderApp* app = context;
     app->selected_tx_string = items[index].item_string;
     app->selected_tx_string = items[index].item_string;
+    app->is_command = (2 <= index);
     app->is_custom_tx_string = false;
     app->is_custom_tx_string = false;
     app->selected_menu_index = index;
     app->selected_menu_index = index;
     app->focus_console_start = items[index].focus_console_start;
     app->focus_console_start = items[index].focus_console_start;

+ 1 - 0
applications/wifi_marauder_companion/wifi_marauder_app_i.h

@@ -32,6 +32,7 @@ struct WifiMarauderApp {
     WifiMarauderUart* uart;
     WifiMarauderUart* uart;
     int selected_menu_index;
     int selected_menu_index;
     const char* selected_tx_string;
     const char* selected_tx_string;
+    bool is_command;
     bool is_custom_tx_string;
     bool is_custom_tx_string;
     bool focus_console_start;
     bool focus_console_start;
 };
 };