From 59219a05ec7a1ac5e0b6764cccdf1f0b7646d548 Mon Sep 17 00:00:00 2001 From: Niel Nielsen Date: Mon, 31 Aug 2026 08:42:09 +0200 Subject: [PATCH] Refactor BWM forward handling and comments Updated comments for clarity and changed baud rate assignment to use negotiated value. Signed-off-by: Niel Nielsen --- armsrc/appmain.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index ce1a73848..df27d92fa 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -24,6 +24,7 @@ #include "usb_cdc_apis.h" #ifdef WITH_BWM_FORWARD #include "bwm_uart_at32.h" +#include "bwm_forward.h" // bwm_fwd_negotiate_baud() #include "bwm_wifi.h" #endif #include "proxmark3_arm.h" @@ -700,10 +701,11 @@ static void SendCapabilities(void) { capabilities.baudrate = g_usart_baudrate; #endif #ifdef WITH_BWM_FORWARD - // BWM link runs at a fixed baud; report it so the client's timeout math - // (communication_delay: 12000000 / uart_speed) doesn't divide by zero. + // Report the negotiated link baud so the client's timeout math + // (communication_delay: 12000000 / uart_speed) matches reality and never + // divides by zero. if (g_reply_via_fpc) - capabilities.baudrate = BWM_UART_BAUD; + capabilities.baudrate = bwm_uart_get_baud(); #endif #ifdef RDV4 @@ -4011,6 +4013,9 @@ void __attribute__((noreturn)) AppMain(void) { #ifdef WITH_BWM_FORWARD bwm_uart_init(); // AT32 UART4 <-> BWM app_com link; AFTER usb_enable() + // Negotiate the link up from the boot baud; harmless no-op if the ESP is + // older or the target is unreachable (stays at BWM_UART_BAUD). + bwm_fwd_negotiate_baud(BWM_UART_BAUD_TARGET); #endif #ifdef WITH_BWM_CHARGERKICK