Skip to content
Open
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
fc31a5e
Patch manifest
haslinghuis Oct 29, 2025
ae221c4
Updte workflow
haslinghuis Oct 29, 2025
b6b31db
Use tauri-plugin-serialplugin
haslinghuis Oct 29, 2025
74a3266
Fix build
haslinghuis Oct 29, 2025
983a9cf
Use Kotlin DSL syntax, not Groovy
haslinghuis Oct 29, 2025
c2163bd
Replace sed with awk
haslinghuis Oct 29, 2025
0533869
Downgrade tauri-plugin-serialplugin to 2.10.0 in Cargo.lock
haslinghuis Oct 29, 2025
a801f59
Upgrade to tauri-plugin-serialplugin 2.16.0 for Android USB support
haslinghuis Oct 29, 2025
cadf39f
Add Android USB debugging tools and updated documentation
haslinghuis Oct 29, 2025
eb441f4
Fix manifest patching: replace sed with awk for cross-platform compat…
haslinghuis Oct 29, 2025
8c93e03
Add custom MainActivity with USB runtime permission handling
haslinghuis Oct 29, 2025
b1c3154
Update debugging docs with MainActivity testing instructions
haslinghuis Oct 29, 2025
0a60f3e
Fix MainActivity import: add missing TauriActivity import
haslinghuis Oct 29, 2025
2eb9aaa
Nitpicks
haslinghuis Oct 29, 2025
cd6aa1f
Fix JitPack repository injection: use settings.gradle.kts with Kotlin…
haslinghuis Oct 29, 2025
2f2e9ab
Move JitPack repository injection into patch script
haslinghuis Oct 29, 2025
e9c511e
Inject JitPack into dependencyResolutionManagement.repositories in se…
haslinghuis Oct 29, 2025
3d13b6e
Revert usb-serial-for-android to 3.8.0 and harden JitPack injection
haslinghuis Oct 29, 2025
d71a7c1
Fix grep alternation and duplicate -n in JitPack repo preview
haslinghuis Oct 29, 2025
04b8256
Force usb-serial-for-android to 3.8.0 and remove FAIL_ON_PROJECT_REPO…
haslinghuis Oct 29, 2025
99642e8
Fix Kotlin DSL syntax error - use resolutionStrategy instead of isForce
haslinghuis Oct 29, 2025
aa9ddc8
Add debug output to show settings.gradle.kts before and after JitPack…
haslinghuis Oct 29, 2025
8d87c20
Add JitPack repository directly to app build.gradle.kts as fallback
haslinghuis Oct 29, 2025
37fb1b6
Remove custom MainActivity - not needed for USB serial permissions
haslinghuis Oct 29, 2025
6d79317
Add extensive debug logging for Android USB enumeration
haslinghuis Oct 29, 2025
a826b93
Add ADB wireless debugging setup for Android USB testing
haslinghuis Oct 29, 2025
4a32b85
Fix ADB wireless setup script to support IPv6 addresses
haslinghuis Oct 29, 2025
b85212b
Add comprehensive next steps guide for Android USB debugging
haslinghuis Oct 29, 2025
792d918
Add local Android build script: init + patch + dev/release + signing …
haslinghuis Oct 29, 2025
735ac48
feat(android): enable USB serial support with debugging capabilities
haslinghuis Oct 29, 2025
1d19205
docs: add Android USB serial status and progress tracking
haslinghuis Oct 29, 2025
9416e32
Shell improvement
haslinghuis Oct 29, 2025
1331237
Default is not needed when using explicit permissions
haslinghuis Oct 29, 2025
4435a99
No need for HMR_HOST
haslinghuis Oct 29, 2025
bb84552
Forgot to include
haslinghuis Oct 29, 2025
90cecf7
Address 'Warning: src-tauri/gen/android/settings.gradle.kts not found…
haslinghuis Oct 30, 2025
83122fc
Address 'Warning: src-tauri/gen/android/settings.gradle.kts not found…
haslinghuis Oct 30, 2025
7e03458
little cleanup
haslinghuis Oct 30, 2025
b7f391a
Update scripts
haslinghuis Nov 3, 2025
0a0bf83
Fix android debugging
haslinghuis Nov 3, 2025
62f9c41
???
haslinghuis Nov 3, 2025
05bc006
Add dependency for usb-serial-for-android
haslinghuis Nov 3, 2025
5ec9332
Address CR nitpick
haslinghuis Nov 3, 2025
cb3680a
After running cargo update
haslinghuis Nov 3, 2025
5f31190
Fix working versions
haslinghuis Nov 3, 2025
a93186b
Dependency hell
haslinghuis Nov 3, 2025
8e779cd
Which version works ???
haslinghuis Nov 3, 2025
72173cf
Fix script portability
haslinghuis Nov 3, 2025
56f041f
modify the patch script to add the repository directly to build.gradl…
haslinghuis Nov 3, 2025
4dfd15e
refactor scripts for single responsibility
haslinghuis Nov 3, 2025
c19e84c
Using js API instead of Rust invoke
haslinghuis Nov 6, 2025
bf62596
Fix USB permission issue
haslinghuis Nov 6, 2025
220037c
Fix port enumeration
haslinghuis Nov 6, 2025
0e4c4c7
Some cleanup
haslinghuis Nov 6, 2025
6dea4b3
Read is not solved
haslinghuis Nov 6, 2025
7e5ce52
Apply custom MainActivity.kt
haslinghuis Nov 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Setup Java 17
- name: Setup Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Android SDK
uses: android-actions/setup-android@v3
Expand All @@ -151,6 +151,9 @@ jobs:
- name: Initialize Tauri Android project
run: yarn tauri android init --ci

- name: Patch Android manifest for USB support
run: bash scripts/patch-android-manifest.sh

- name: Build Tauri Android APK
uses: tauri-apps/tauri-action@v0
with:
Expand Down
126 changes: 126 additions & 0 deletions ANDROID_USB_STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Android USB Serial - Current Status

## ✅ Working

1. **Build System**
- Debug and release APK builds successfully
- Wireless ADB deployment working
- Local build script with validation mode
- Robust Tauri CLI detection (cargo/npx/yarn fallbacks)

2. **Development Environment**
- WebView debugging enabled (chrome://inspect)
- Vite dev server accessible over WiFi (0.0.0.0 binding)
- HMR working over network
- Console logs visible in Chrome DevTools

3. **Serial Plugin Integration**
- Plugin registered in mobile entry point (`lib.rs`)
- All required permissions granted in capabilities
- Plugin properly initialized on Android

4. **USB Detection**
- ✅ **USB device IS BEING DETECTED!**
- Device path: `/dev/bus/usb/002/002`
- VID: `1155` (0x0483 - STMicroelectronics)
- PID: `22336` (0x5740 - Betaflight)
- Manufacturer: `Betaflight`
- Product: `Betaflight STM32H743`
- Serial Number: `367838603330`

## 🔧 Known Issues

### 1. USB Permission Not Granted
**Error:** `User has not given 10339/com.betaflight.app permission to access device /dev/bus/usb/002/002`

**Status:** Android detects the device but hasn't granted permission to access it.

**Possible Solutions:**
- Implement runtime permission request when device is detected
- Handle USB_DEVICE_ATTACHED intent more actively
- Check if plugin has a permission request method
- May need custom Android code to trigger permission dialog

### 2. Response Deserialization Error
**Error:** `failed to deserialize response: invalid type: string "{/dev/bus/usb/002/002={...}}", expected a map`

**Status:** The Android plugin returns a string representation instead of proper JSON.

**Possible Solutions:**
- Parse the string response in JavaScript before deserialization
- Check if newer plugin version fixes this
- Implement custom response handler

## 📋 Next Steps

### Priority 1: USB Permission Handling
1. Research tauri-plugin-serialplugin Android permission APIs
2. Implement permission request flow:
- Detect when permission is needed
- Request permission from Android
- Handle permission grant/deny
3. Test with manual permission grant (Android Settings → Apps → Betaflight → Permissions)

### Priority 2: Fix Response Parsing
1. Add response preprocessing in TauriSerial.js
2. Parse string format: `{/dev/path={key=value, ...}}`
3. Convert to expected JSON structure

### Priority 3: End-to-End Testing
1. Verify port enumeration with permission granted
2. Test port opening/closing
3. Test serial communication (read/write)
4. Test device attach/detach events

## 🔍 Debugging Setup

### Connect via Wireless ADB
```bash
# Start ADB over WiFi
./scripts/setup-adb-wifi.sh

# Or manually
adb tcpip 5555
adb connect <device-ip>:5555
```

### View Console Logs
1. Open `chrome://inspect` in Chrome
2. Find "WebView in com.betaflight.app"
3. Click "inspect"
4. Console shows all debug logs including USB detection

### Build and Install Debug APK
```bash
# Build and install debuggable APK
./scripts/build-android-local.sh dev

# Or manually
source ./android-env.sh
cargo tauri android build --apk --debug
adb install -r src-tauri/gen/android/app/build/outputs/apk/universal/debug/app-universal-debug.apk
```

## 📁 Key Files

- `src-tauri/src/lib.rs` - Mobile entry point with serial plugin registration
- `src-tauri/capabilities/default.json` - Tauri permissions for Android
- `scripts/patch-android-manifest.sh` - Adds USB permissions and device filters
- `scripts/build-android-local.sh` - Local development build automation
- `src/js/protocols/TauriSerial.js` - Serial protocol implementation
- `vite.config.js` - Network binding for wireless development

## 🎯 Success Criteria

- [x] APK builds without errors
- [x] WebView debugging accessible
- [x] USB device detected
- [ ] USB permission granted
- [ ] Port enumeration returns valid devices
- [ ] Can open serial connection
- [ ] Can read/write to serial port
- [ ] Device attach/detach events work

## 📊 Current Progress: ~80%

The infrastructure is in place and USB detection is working. Only permission handling and response parsing remain before full functionality.
Loading