Skip to content

Commit cd4f624

Browse files
wipe logs once saved. don't log reset output.
1 parent 8e2487b commit cd4f624

4 files changed

+21
-11
lines changed

evil_portal_app.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Evil_PortalApp *evil_portal_app_alloc() {
2828

2929
app->sent_html = false;
3030
app->sent_ap = false;
31-
app->has_command_queue = false;
31+
app->sent_reset = false;
32+
app->has_command_queue = false;
3233
app->command_index = 0;
3334
app->portal_logs = malloc(5000);
3435

@@ -74,6 +75,7 @@ void evil_portal_app_free(Evil_PortalApp *app) {
7475
// save latest logs
7576
if (strlen(app->portal_logs) > 0) {
7677
write_logs(app->portal_logs);
78+
free(app->portal_logs);
7779
}
7880

7981
// Send reset event to dev board

evil_portal_app_i.h

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct Evil_PortalApp {
4646
bool show_stopscan_tip;
4747
bool sent_ap;
4848
bool sent_html;
49+
bool sent_reset;
4950
int BAUDRATE;
5051

5152
uint8_t *index_html;

evil_portal_uart.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ static int32_t uart_worker(void *context) {
5151
if (uart->handle_rx_data_cb) {
5252
uart->handle_rx_data_cb(uart->rx_buf, len, uart->app);
5353

54-
if (uart->app->has_command_queue) {
55-
if (uart->app->command_index < 1) {
54+
if (uart->app->has_command_queue) {
55+
if (uart->app->command_index < 1) {
5656
if (0 ==
5757
strncmp(SET_AP_CMD,
5858
uart->app->command_queue[uart->app->command_index],
59-
strlen(SET_AP_CMD))) {
59+
strlen(SET_AP_CMD))) {
6060
char *out_data =
6161
malloc((size_t)(strlen((char *)uart->app->ap_name) +
6262
strlen("setap=")));
@@ -78,10 +78,14 @@ static int32_t uart_worker(void *context) {
7878
}
7979
}
8080

81-
strcat(uart->app->portal_logs, (char *)uart->rx_buf);
81+
if (uart->app->sent_reset == false) {
82+
strcat(uart->app->portal_logs, (char *)uart->rx_buf);
83+
}
84+
8285
if (strlen(uart->app->portal_logs) > 4000) {
8386
write_logs(uart->app->portal_logs);
8487
free(uart->app->portal_logs);
88+
strcpy(uart->app->portal_logs, "");
8589
}
8690
}
8791
}

scenes/evil_portal_scene_console_output.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void evil_portal_scene_console_output_on_enter(void *context) {
3636
if (app->is_command) {
3737
furi_string_reset(app->text_box_store);
3838
app->text_box_store_strlen = 0;
39+
app->sent_reset = false;
3940

4041
if (0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
4142
const char *help_msg =
@@ -54,18 +55,18 @@ void evil_portal_scene_console_output_on_enter(void *context) {
5455
const char *help_msg = "Logs saved.\n\n";
5556
furi_string_cat_str(app->text_box_store, help_msg);
5657
app->text_box_store_strlen += strlen(help_msg);
57-
if(strlen(app->portal_logs) > 0) {
58-
write_logs(app->portal_logs);
59-
free(app->portal_logs);
60-
}
58+
write_logs(app->portal_logs);
59+
free(app->portal_logs);
60+
strcpy(app->portal_logs, "");
6161
if (app->show_stopscan_tip) {
6262
const char *msg = "Press BACK to return\n";
6363
furi_string_cat_str(app->text_box_store, msg);
6464
app->text_box_store_strlen += strlen(msg);
6565
}
6666
}
6767

68-
if (0 == strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
68+
if (0 ==
69+
strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
6970
app->command_queue[0] = SET_AP_CMD;
7071
app->has_command_queue = true;
7172
app->command_index = 0;
@@ -78,6 +79,7 @@ void evil_portal_scene_console_output_on_enter(void *context) {
7879
}
7980

8081
if (0 == strncmp(RESET_CMD, app->selected_tx_string, strlen(RESET_CMD))) {
82+
app->sent_reset = true;
8183
if (app->show_stopscan_tip) {
8284
const char *msg = "Reseting portal\nPress BACK to return\n\n\n\n";
8385
furi_string_cat_str(app->text_box_store, msg);
@@ -98,7 +100,8 @@ void evil_portal_scene_console_output_on_enter(void *context) {
98100
app->uart, evil_portal_console_output_handle_rx_data_cb);
99101

100102
if (app->is_command && app->selected_tx_string) {
101-
if (0 == strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
103+
if (0 ==
104+
strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
102105
evil_portal_read_index_html(context);
103106

104107
char *data = malloc(

0 commit comments

Comments
 (0)