From cd4f62426407c26979f84db22ed9c46a3febc42d Mon Sep 17 00:00:00 2001 From: bigbrodude6119 <138256922+bigbrodude6119@users.noreply.github.com> Date: Mon, 3 Jul 2023 18:22:44 -0700 Subject: [PATCH] wipe logs once saved. don't log reset output. --- evil_portal_app.c | 4 +++- evil_portal_app_i.h | 1 + evil_portal_uart.c | 12 ++++++++---- scenes/evil_portal_scene_console_output.c | 15 +++++++++------ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/evil_portal_app.c b/evil_portal_app.c index 85bf9ddeb7b..a1b6c3d9055 100644 --- a/evil_portal_app.c +++ b/evil_portal_app.c @@ -28,7 +28,8 @@ Evil_PortalApp *evil_portal_app_alloc() { app->sent_html = false; app->sent_ap = false; - app->has_command_queue = false; + app->sent_reset = false; + app->has_command_queue = false; app->command_index = 0; app->portal_logs = malloc(5000); @@ -74,6 +75,7 @@ void evil_portal_app_free(Evil_PortalApp *app) { // save latest logs if (strlen(app->portal_logs) > 0) { write_logs(app->portal_logs); + free(app->portal_logs); } // Send reset event to dev board diff --git a/evil_portal_app_i.h b/evil_portal_app_i.h index 5379eaab876..3f31659d081 100644 --- a/evil_portal_app_i.h +++ b/evil_portal_app_i.h @@ -46,6 +46,7 @@ struct Evil_PortalApp { bool show_stopscan_tip; bool sent_ap; bool sent_html; + bool sent_reset; int BAUDRATE; uint8_t *index_html; diff --git a/evil_portal_uart.c b/evil_portal_uart.c index 46c43eb8e8b..ab6af87f171 100644 --- a/evil_portal_uart.c +++ b/evil_portal_uart.c @@ -51,12 +51,12 @@ static int32_t uart_worker(void *context) { if (uart->handle_rx_data_cb) { 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 == strncmp(SET_AP_CMD, uart->app->command_queue[uart->app->command_index], - strlen(SET_AP_CMD))) { + strlen(SET_AP_CMD))) { char *out_data = malloc((size_t)(strlen((char *)uart->app->ap_name) + 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) { write_logs(uart->app->portal_logs); free(uart->app->portal_logs); + strcpy(uart->app->portal_logs, ""); } } } diff --git a/scenes/evil_portal_scene_console_output.c b/scenes/evil_portal_scene_console_output.c index 97873a52b73..e6367dcac24 100644 --- a/scenes/evil_portal_scene_console_output.c +++ b/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) { furi_string_reset(app->text_box_store); app->text_box_store_strlen = 0; + app->sent_reset = false; if (0 == strncmp("help", app->selected_tx_string, strlen("help"))) { 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"; furi_string_cat_str(app->text_box_store, 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) { const char *msg = "Press BACK to return\n"; 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->has_command_queue = true; 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))) { + app->sent_reset = true; if (app->show_stopscan_tip) { const char *msg = "Reseting portal\nPress BACK to return\n\n\n\n"; 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); 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); char *data = malloc(