Skip to content

Commit

Permalink
wipe logs once saved. don't log reset output.
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbrodude6119 committed Jul 4, 2023
1 parent 8e2487b commit cd4f624
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
4 changes: 3 additions & 1 deletion evil_portal_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions evil_portal_app_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions evil_portal_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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=")));
Expand All @@ -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, "");
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions scenes/evil_portal_scene_console_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -54,18 +55,18 @@ 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);
app->text_box_store_strlen += strlen(msg);
}
}

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;
Expand All @@ -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);
Expand All @@ -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(
Expand Down

0 comments on commit cd4f624

Please sign in to comment.