From 64fb78590ed42ec11c06746eddab9362b7d21875 Mon Sep 17 00:00:00 2001 From: Ashin Walpola Date: Mon, 10 Aug 2026 11:38:01 +0200 Subject: [PATCH] Phase 03: ESP32-C5 serial link hardening + bench diagnostics Enumeration: - Merge the library's stock probe table instead of replacing it, so adding Espressif 0x303A/0x1001 doesn't drop every other supported device - Select the ESP32-C5 by VID/PID rather than list position - Log USB interface descriptors to distinguish CDC data from the JTAG interface Lifecycle: - Don't close the shared port in MqttViewModel.onCleared() - the foreground recording service outlives the ViewModel and would beacon into a dead port - Handle ACTION_USB_DEVICE_DETACHED so the UI stops reporting a stale link - Implement the STATUS heartbeat on both sides (1 Hz) plus a phone-side watchdog - Surface write failures and firmware drop counters on the CAM Pinger card Protocol: - Assert DTR/RTS on open (unverified on hardware - see FLASHING.md step 5) - Raise SERIAL_LINK_MAX_PAYLOAD 160 -> 512 on both sides; real third-party CAMs exceed 160 and were being silently dropped at the resync branch - Move the enlarged buffers off task stacks; serialize send_frame with a mutex Firmware and app must be updated together - a 512/160 mismatch fails silently. --- .idea/deploymentTargetSelector.xml | 2 +- .../com/hawhamburg/micr0bu/MainActivity.kt | 13 +- .../micr0bu/data/cam/CamUseCaseRepository.kt | 10 + .../data/mqtt/ObuHardwarePreferences.kt | 15 + .../micr0bu/data/transport/ObuHardware.kt | 8 +- .../micr0bu/data/transport/SerialFrame.kt | 56 +- .../data/transport/UsbSerialTransport.kt | 387 ++- .../ui/screens/ConnectionSetupScreen.kt | 75 +- .../micr0bu/ui/screens/DashboardScreen.kt | 22 +- .../ui/screens/MqttTopicViewerScreen.kt | 173 ++ .../micr0bu/ui/screens/SettingsScreen.kt | 44 + .../micr0bu/viewmodel/MqttViewModel.kt | 53 + app/src/main/res/values-de/strings.xml | 23 +- app/src/main/res/values/strings.xml | 23 +- its-g5-receiver-firmware | 2 +- obu-firmware/main/CMakeLists.txt | 6 +- obu-firmware/main/main.c | 11 +- obu-firmware/main/serial_link.c | 152 +- obu-firmware/main/serial_link.h | 69 +- obu-firmware/sdkconfig | 2528 ++++++++++++++--- 20 files changed, 3076 insertions(+), 596 deletions(-) diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml index c07d1d1..847499e 100644 --- a/.idea/deploymentTargetSelector.xml +++ b/.idea/deploymentTargetSelector.xml @@ -4,7 +4,7 @@