Add Android USB serial bridge docs

This commit is contained in:
lenn
2026-05-11 22:30:45 +08:00
parent c5f4f854bf
commit 360b57e3e2
10 changed files with 395 additions and 100 deletions

View File

@@ -10,6 +10,16 @@ use commands::serial::SerialConnectionState;
#[cfg(feature = "devkit")]
use tauri::Manager;
#[cfg(target_os = "android")]
fn usb_serial_plugin<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("usb-serial")
.setup(|_app, api| {
api.register_android_plugin("com.lenn.tauri_serial", "UsbSerialPlugin")?;
Ok(())
})
.build()
}
#[cfg(feature = "devkit")]
fn start_server_exe(exe_path: &std::path::Path) {
let mut command = std::process::Command::new(exe_path);
@@ -66,6 +76,9 @@ pub fn run() {
.manage(SerialConnectionState::default())
.plugin(tauri_plugin_opener::init());
#[cfg(target_os = "android")]
let builder = builder.plugin(usb_serial_plugin());
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let builder = builder.plugin(tauri_plugin_updater::Builder::new().build());
@@ -177,7 +190,6 @@ pub fn run() {
let builder = builder.invoke_handler(tauri::generate_handler![
commands::file_explorer::file_explorer_list,
commands::serial::serial_enum,
commands::serial::serial_connect,
commands::serial::serial_connect_fd,
commands::serial::serial_disconnect,
commands::serial::serial_export_csv,
@@ -200,7 +212,6 @@ pub fn run() {
let builder = builder.invoke_handler(tauri::generate_handler![
commands::file_explorer::file_explorer_list,
commands::serial::serial_enum,
commands::serial::serial_connect,
commands::serial::serial_connect_fd,
commands::serial::serial_disconnect,
commands::serial::serial_export_csv,