1 Commits

Author SHA1 Message Date
LIAUD Corentin
6210a6a587 feat: add logcat + log crate 2024-09-05 16:53:23 +02:00
6 changed files with 10 additions and 21 deletions

View File

@@ -6,7 +6,7 @@ resolver = "2"
edition = "2021"
license = "MIT"
repository = "https://github.com/cocool97/adb_client"
version = "1.0.6"
version = "1.0.5"
# To build locally when working on a new version
[patch.crates-io]

View File

@@ -9,7 +9,7 @@ repository.workspace = true
version.workspace = true
[dependencies]
adb_client = { version = "1.0.6" }
adb_client = { version = "1.0.5" }
anyhow = { version = "1.0.86" }
clap = { version = "4.5.17", features = ["derive"] }
env_logger = { version = "0.11.5" }

View File

@@ -16,7 +16,7 @@ pub enum HostCommand {
/// Track new devices showing up.
TrackDevices,
/// Pair device with a given code
Pair { address: SocketAddrV4, code: String },
Pair { address: SocketAddrV4, code: u32 },
/// Connect device over WI-FI
Connect { address: SocketAddrV4 },
/// Disconnect device over WI-FI

View File

@@ -19,17 +19,17 @@ adb_client = "*"
### Launch a command on device via ADB server
```rust no_run
```rust
use adb_client::ADBServer;
let mut server = ADBServer::default();
let mut device = server.get_device().expect("cannot get device");
device.shell_command(["df", "-h"],std::io::stdout());
device.shell_command(["df", "-h"]);
```
### Get available ADB devices
```rust no_run
```rust
use adb_client::ADBServer;
use std::net::{SocketAddrV4, Ipv4Addr};
@@ -43,7 +43,7 @@ server.devices();
### Push a file to the device
```rust no_run
```rust
use adb_client::ADBServer;
use std::net::Ipv4Addr;
use std::fs::File;

View File

@@ -13,7 +13,7 @@ pub(crate) enum AdbServerCommand {
HostFeatures,
Connect(SocketAddrV4),
Disconnect(SocketAddrV4),
Pair(SocketAddrV4, String),
Pair(SocketAddrV4, u32),
TransportAny,
TransportSerial(String),
// Local commands
@@ -50,20 +50,9 @@ impl Display for AdbServerCommand {
AdbServerCommand::Connect(addr) => write!(f, "host:connect:{}", addr),
AdbServerCommand::Disconnect(addr) => write!(f, "host:disconnect:{}", addr),
AdbServerCommand::Pair(addr, code) => {
write!(f, "host:pair:{code}:{addr}")
write!(f, "host:pair:{code}:{}", addr)
}
AdbServerCommand::FrameBuffer => write!(f, "framebuffer:"),
}
}
}
#[test]
fn test_pair_command() {
let host = "192.168.0.197:34783";
let code = "091102";
let code_u32 = code.parse::<u32>().expect("cannot parse u32");
let pair = AdbServerCommand::Pair(host.parse().expect("cannot parse host"), code.into());
assert_eq!(pair.to_string(), format!("host:pair:{code}:{host}"));
assert_ne!(pair.to_string(), format!("host:pair:{code_u32}:{host}"))
}

View File

@@ -4,7 +4,7 @@ use std::net::SocketAddrV4;
impl ADBServer {
/// Pair device on a specific port with a generated 'code'
pub fn pair(&mut self, address: SocketAddrV4, code: String) -> Result<()> {
pub fn pair(&mut self, address: SocketAddrV4, code: u32) -> Result<()> {
let response = self
.connect()?
.proxy_connection(AdbServerCommand::Pair(address, code), true)?;