From fb32df37c8cde3775f1c0bb9ea541c718ee78d36 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Tue, 26 May 2026 07:54:53 +0200 Subject: [PATCH] =?UTF-8?q?fix(ui):=20trail=20GPX=20export=20=E2=80=94=20g?= =?UTF-8?q?uard=20against=20USB-app=20collision?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Wio L1 DualSerialInterface multiplexes BLE + USB on the same frame protocol: when BLE is connected, the USB receive path is ignored, so we can safely push raw GPX bytes to USB without confusing the companion app. When BLE is *not* connected the app is talking over USB itself — the dump would land mid-frame and the app would parse garbage. Block the export when hasConnection() (BLE link to the app) is false and show "Connect BLE or disconnect app". When it's true the dump runs and the confirm alert reads "GPX N B over USB" so the user knows which pipe to read from. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/ui-new/TrailScreen.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/companion_radio/ui-new/TrailScreen.h b/examples/companion_radio/ui-new/TrailScreen.h index 81699448..da71430c 100644 --- a/examples/companion_radio/ui-new/TrailScreen.h +++ b/examples/companion_radio/ui-new/TrailScreen.h @@ -165,11 +165,20 @@ private: _task->showAlert(ok ? "Trail loaded" : "Load failed", 800); } void handleExport() { - if (!Serial) { _task->showAlert("Connect USB first", 1000); return; } + if (!Serial) { _task->showAlert("Connect USB first", 1200); return; } + // The companion app multiplexes BLE + USB on the same frame protocol. + // When BLE is connected, USB-receive is ignored and we can safely push + // raw GPX bytes to USB. With BLE off the app would be on USB itself, + // so the dump would corrupt its incoming frames — refuse and tell the + // user how to make space. + if (!_task->hasConnection()) { + _task->showAlert("Connect BLE or disconnect app", 1500); + return; + } size_t n = _store->exportGpx(Serial); char alert[24]; - snprintf(alert, sizeof(alert), "GPX %u B sent", (unsigned)n); - _task->showAlert(alert, 1200); + snprintf(alert, sizeof(alert), "GPX %u B over USB", (unsigned)n); + _task->showAlert(alert, 1500); } static constexpr const char* TRAIL_FILE = "/trail";