Skip to content

Commit

Permalink
removed var
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbrodude6119 committed Jun 30, 2023
1 parent e45e6b4 commit 2b618e2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 73 deletions.
1 change: 0 additions & 1 deletion evil_portal_app_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ struct Evil_PortalApp {
bool sent_ap;
bool sent_html;
int BAUDRATE;
int TERMINAL_MODE; // 1=AT mode, 0=other mode

uint8_t *index_html;
uint8_t *ap_name;
Expand Down
19 changes: 0 additions & 19 deletions evil_portal_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#include "evil_portal_uart.h"
#include "helpers/evil_portal_storage.h"

// #define UART_CH (FuriHalUartIdUSART1)
// #define BAUDRATE (115200)

struct Evil_PortalUart {
Evil_PortalApp *app;
FuriThread *rx_thread;
Expand Down Expand Up @@ -82,24 +79,8 @@ static int32_t uart_worker(void *context) {
uart->app->has_command_queue = false;
uart->app->command_queue[0] = "";
}

// if(0 == strncmp("ack", (char *)uart->rx_buf, strlen("ack"))) {

// } else {
// uart->app->command_index = 0;
// uart->app->has_command_queue = false;
// uart->app->command_queue[0] = "";
// }
// }
}

// rx_buf has response
// wait for ack
// if response is ack
// check for commands
// if has commands
// send next command

strcat(uart->app->portal_logs, (char *)uart->rx_buf);
if (strlen(uart->app->portal_logs) > 4000) {
write_logs(uart->app->portal_logs);
Expand Down
100 changes: 47 additions & 53 deletions scenes/evil_portal_scene_console_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,63 +102,57 @@ void evil_portal_scene_console_output_on_enter(void *context) {
// Send command with CR+LF or newline '\n'
// it is sent here
if (app->is_command && app->selected_tx_string) {
if (app->TERMINAL_MODE == 1) {

// handle special commands here
if (0 == strncmp("sethtml", app->selected_tx_string, strlen("sethtml"))) {
evil_portal_read_index_html(context);

char *data = malloc(
(size_t)(strlen((char *)app->index_html) + strlen("sethtml=")));
strcat(data, "sethtml=");
strcat(data, (char *)app->index_html);

evil_portal_uart_tx((uint8_t *)(data), strlen(data));
evil_portal_uart_tx((uint8_t *)("\n"), 1);

app->sent_html = true;

free(data);
free(app->index_html);

evil_portal_read_ap_name(context);
} else if (0 ==
strncmp("setap", app->selected_tx_string, strlen("setap"))) {

evil_portal_read_ap_name(context);

char *data =
malloc((size_t)(strlen((char *)app->ap_name) + strlen("setap=")));
strcat(data, "setap=");
strcat(data, (char *)app->ap_name);

evil_portal_uart_tx((uint8_t *)(data), strlen(data));
evil_portal_uart_tx((uint8_t *)("\n"), 1);

app->sent_ap = true;

free(data);
free(app->ap_name);
} else if (0 ==
strncmp("reset", app->selected_tx_string, strlen("reset"))) {
app->sent_html = false;
app->sent_ap = false;
evil_portal_uart_tx((uint8_t *)(app->selected_tx_string),
strlen(app->selected_tx_string));
evil_portal_uart_tx((uint8_t *)("\r\n"), 2);
evil_portal_uart_tx((uint8_t *)("\n"), 1);
} else if (0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
// nothing to do
} else {
// handle special commands here
if (0 == strncmp("sethtml", app->selected_tx_string, strlen("sethtml"))) {
evil_portal_read_index_html(context);

char *data = malloc(
(size_t)(strlen((char *)app->index_html) + strlen("sethtml=")));
strcat(data, "sethtml=");
strcat(data, (char *)app->index_html);

evil_portal_uart_tx((uint8_t *)(data), strlen(data));
evil_portal_uart_tx((uint8_t *)("\n"), 1);

app->sent_html = true;

free(data);
free(app->index_html);

evil_portal_read_ap_name(context);
} else if (0 ==
strncmp("setap", app->selected_tx_string, strlen("setap"))) {

evil_portal_read_ap_name(context);

char *data =
malloc((size_t)(strlen((char *)app->ap_name) + strlen("setap=")));
strcat(data, "setap=");
strcat(data, (char *)app->ap_name);

evil_portal_uart_tx((uint8_t *)(data), strlen(data));
evil_portal_uart_tx((uint8_t *)("\n"), 1);

app->sent_ap = true;

free(data);
free(app->ap_name);
} else if (0 ==
strncmp("reset", app->selected_tx_string, strlen("reset"))) {
app->sent_html = false;
app->sent_ap = false;
evil_portal_uart_tx((uint8_t *)(app->selected_tx_string),
strlen(app->selected_tx_string));
evil_portal_uart_tx((uint8_t *)("\n"), 1);
} else if (0 ==
strncmp("help", app->selected_tx_string, strlen("help"))) {
// do nothing?
} else {
evil_portal_uart_tx((uint8_t *)(app->selected_tx_string),
strlen(app->selected_tx_string));
evil_portal_uart_tx((uint8_t *)("\n"), 1);
}
evil_portal_uart_tx((uint8_t *)(app->selected_tx_string),
strlen(app->selected_tx_string));
evil_portal_uart_tx((uint8_t *)("\n"), 1);
}
}
}
}

bool evil_portal_scene_console_output_on_event(void *context,
Expand Down

0 comments on commit 2b618e2

Please sign in to comment.