From c326c894dfa8d325727bfeb66dcf938031b39d2b Mon Sep 17 00:00:00 2001 From: Sil333033 <94360907+Sil333033@users.noreply.github.com> Date: Sat, 19 Aug 2023 12:29:16 +0200 Subject: [PATCH] XFW esp bin coming soon --nobuild --- .../external/advanced_wifisniff/sniffer.c | 79 +++++++++++-------- .../external/evil_portal/evil_portal_app.c | 5 ++ .../external/evil_portal/evil_portal_uart.c | 2 + 3 files changed, 54 insertions(+), 32 deletions(-) diff --git a/applications/external/advanced_wifisniff/sniffer.c b/applications/external/advanced_wifisniff/sniffer.c index d6cb650ee..ce1a1b193 100644 --- a/applications/external/advanced_wifisniff/sniffer.c +++ b/applications/external/advanced_wifisniff/sniffer.c @@ -101,12 +101,10 @@ static void show_access_point(Canvas* canvas, Context* context) { AccessPoint ap = ctx->active_access_point; - // canvas_draw_str_aligned(canvas, 3, 25, AlignLeft, AlignBottom, ap.ssid); canvas_draw_str_aligned(canvas, 62, 25, AlignCenter, AlignBottom, ap.ssid); canvas_set_font(canvas, FontSecondary); - // canvas_draw_str_aligned(canvas, 43, 12, AlignLeft, AlignBottom, ap.bssid); canvas_draw_str_aligned( canvas, 38 + (ctx->access_points_count > 99 ? 5 : 0), 12, AlignLeft, AlignBottom, ap.bssid); @@ -148,11 +146,9 @@ static void show_access_point(Canvas* canvas, Context* context) { static void render_callback(Canvas* canvas, void* context) { Context* ctx = context; - // hier teken je hoe je projectje eruit ziet - canvas_draw_frame(canvas, 0, 0, 128, 64); - canvas_set_font(canvas, FontPrimary); // groot + canvas_set_font(canvas, FontPrimary); if(ctx->access_points_count >= MAX_ACCESS_POINTS) { canvas_draw_str(canvas, 118, 10, "!"); @@ -163,15 +159,12 @@ static void render_callback(Canvas* canvas, void* context) { canvas_draw_str(canvas, 80, 40, "Found!"); canvas_draw_icon(canvas, 1, 4, &I_DolphinWait_61x59); } else { - // canvas_draw_frame(canvas, 0, 0, 35, 15); canvas_draw_frame(canvas, 0, 0, 35 + (ctx->access_points_count > 99 ? 5 : 0), 15); furi_string_printf( ctx->buffer, "%d/%d", ctx->access_points_index + 1, ctx->access_points_count); canvas_draw_str(canvas, 3, 12, furi_string_get_cstr(ctx->buffer)); - // canvas_draw_str_aligned( - // canvas, 20, 12, AlignCenter, AlignBottom, furi_string_get_cstr(ctx->buffer)); show_access_point(canvas, ctx); } @@ -238,7 +231,6 @@ static void parseLine(void* context, char* line) { while(token != NULL) { switch(i) { case 0: - // strcpy(ap.ssid, token); if(strcmp(token, "AR") == 0) { isAp = true; isValid = true; @@ -436,8 +428,6 @@ static int32_t uart_worker_esp(void* context) { // put a null terminator in place of the newline, to delimit the line string *newline = '\0'; - // FURI_LOG_I(appname, "Received line: %s", line_current); - parseLine(ctx, line_current); // move the cursor to the character after the newline @@ -593,8 +583,25 @@ static int32_t uart_worker_gps(void* context) { int32_t wifisniffer_app(void* p) { UNUSED(p); - // alloc everything + // if(UART_CH_ESP == UART_CH_GPS) { + // FURI_LOG_I(appname, "ESP and GPS uart can't be the same"); + // return -1; + // } + // turn off 5v, so it gets reset on startup + if(furi_hal_power_is_otg_enabled()) { + furi_hal_power_disable_otg(); + } + + // Enable 5v on startup + uint8_t attempts = 0; + while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { + furi_hal_power_enable_otg(); + furi_delay_ms(10); + } + furi_delay_ms(200); + + // alloc everything Context* ctx = malloc(sizeof(Context)); ctx->queue = furi_message_queue_alloc(8, sizeof(Event)); ctx->mutex = furi_mutex_alloc(FuriMutexTypeNormal); @@ -608,7 +615,6 @@ int32_t wifisniffer_app(void* p) { ctx->pressedButton = false; //esp uart - ctx->rx_stream_esp = furi_stream_buffer_alloc(RX_BUF_SIZE * 5, 1); ctx->thread_esp = furi_thread_alloc(); @@ -622,31 +628,34 @@ int32_t wifisniffer_app(void* p) { if(UART_CH_ESP == FuriHalUartIdUSART1) { furi_hal_console_disable(); } else if(UART_CH_ESP == FuriHalUartIdLPUART1) { - furi_hal_uart_init(UART_CH_ESP, 9600); + furi_hal_uart_init(UART_CH_ESP, 115200); } - furi_hal_uart_set_br(UART_CH_ESP, 9600); + furi_hal_uart_set_br(UART_CH_ESP, 115200); furi_hal_uart_set_irq_cb(UART_CH_ESP, uart_cb_esp, ctx); + + furi_hal_uart_tx(UART_CH_ESP, (uint8_t*)"XFW#WIFISNIFF=1\r\n", strlen("XFW#WIFISNIFF=1\r\n")); //end esp uart //gps uart + if(UART_CH_ESP != UART_CH_GPS) { + ctx->rx_stream_gps = furi_stream_buffer_alloc(RX_BUF_SIZE * 5, 1); - ctx->rx_stream_gps = furi_stream_buffer_alloc(RX_BUF_SIZE * 5, 1); + ctx->thread_gps = furi_thread_alloc(); + furi_thread_set_name(ctx->thread_gps, "LLwifiSnifferUartWorkerGPS"); + furi_thread_set_stack_size(ctx->thread_gps, 2048); + furi_thread_set_context(ctx->thread_gps, ctx); + furi_thread_set_callback(ctx->thread_gps, uart_worker_gps); - ctx->thread_gps = furi_thread_alloc(); - furi_thread_set_name(ctx->thread_gps, "LLwifiSnifferUartWorkerGPS"); - furi_thread_set_stack_size(ctx->thread_gps, 2048); - furi_thread_set_context(ctx->thread_gps, ctx); - furi_thread_set_callback(ctx->thread_gps, uart_worker_gps); + furi_thread_start(ctx->thread_gps); - furi_thread_start(ctx->thread_gps); - - if(UART_CH_GPS == FuriHalUartIdUSART1) { - furi_hal_console_disable(); - } else if(UART_CH_GPS == FuriHalUartIdLPUART1) { - furi_hal_uart_init(UART_CH_GPS, 9600); + if(UART_CH_GPS == FuriHalUartIdUSART1) { + furi_hal_console_disable(); + } else if(UART_CH_GPS == FuriHalUartIdLPUART1) { + furi_hal_uart_init(UART_CH_GPS, 9600); + } + furi_hal_uart_set_br(UART_CH_GPS, 9600); + furi_hal_uart_set_irq_cb(UART_CH_GPS, uart_cb_gps, ctx); } - furi_hal_uart_set_br(UART_CH_GPS, 9600); - furi_hal_uart_set_irq_cb(UART_CH_GPS, uart_cb_gps, ctx); //end gps uart ViewPort* view_port = view_port_alloc(); @@ -792,9 +801,11 @@ int32_t wifisniffer_app(void* p) { furi_thread_join(ctx->thread_esp); furi_thread_free(ctx->thread_esp); - furi_thread_flags_set(furi_thread_get_id(ctx->thread_gps), WorkerEvtStop); - furi_thread_join(ctx->thread_gps); - furi_thread_free(ctx->thread_gps); + if(UART_CH_ESP != UART_CH_GPS) { + furi_thread_flags_set(furi_thread_get_id(ctx->thread_gps), WorkerEvtStop); + furi_thread_join(ctx->thread_gps); + furi_thread_free(ctx->thread_gps); + } storage_file_close(ctx->file); storage_file_free(ctx->file); @@ -816,5 +827,9 @@ int32_t wifisniffer_app(void* p) { furi_hal_console_enable(); } + if(furi_hal_power_is_otg_enabled()) { + furi_hal_power_disable_otg(); + } + return 0; } diff --git a/applications/external/evil_portal/evil_portal_app.c b/applications/external/evil_portal/evil_portal_app.c index 4f985e72c..ef3131f46 100644 --- a/applications/external/evil_portal/evil_portal_app.c +++ b/applications/external/evil_portal/evil_portal_app.c @@ -106,6 +106,11 @@ void evil_portal_app_free(Evil_PortalApp* app) { int32_t evil_portal_app(void* p) { UNUSED(p); + // turn off 5v, so it gets reset on startup + if(furi_hal_power_is_otg_enabled()) { + furi_hal_power_disable_otg(); + } + // Enable 5v on startup uint8_t attempts = 0; while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { diff --git a/applications/external/evil_portal/evil_portal_uart.c b/applications/external/evil_portal/evil_portal_uart.c index 13977e4fb..8d88f7cf9 100644 --- a/applications/external/evil_portal/evil_portal_uart.c +++ b/applications/external/evil_portal/evil_portal_uart.c @@ -135,6 +135,8 @@ Evil_PortalUart* evil_portal_uart_init(Evil_PortalApp* app) { furi_hal_uart_set_br(UART_CH, app->BAUDRATE); furi_hal_uart_set_irq_cb(UART_CH, evil_portal_uart_on_irq_cb, uart); + evil_portal_uart_tx((uint8_t*)("XFW#EVILPORTAL=1\n"), strlen("XFW#EVILPORTAL=1\n")); + return uart; }