mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Add more usbmuxd response codes
This commit is contained in:
@@ -205,6 +205,15 @@ pub enum IdeviceError {
|
|||||||
#[error("device not found")]
|
#[error("device not found")]
|
||||||
DeviceNotFound,
|
DeviceNotFound,
|
||||||
|
|
||||||
|
#[error("device refused connection")]
|
||||||
|
UsbConnectionRefused,
|
||||||
|
#[error("bad command")]
|
||||||
|
UsbBadCommand,
|
||||||
|
#[error("bad device")]
|
||||||
|
UsbBadDevice,
|
||||||
|
#[error("usb bad version")]
|
||||||
|
UsbBadVersion,
|
||||||
|
|
||||||
#[error("unknown error `{0}` returned from device")]
|
#[error("unknown error `{0}` returned from device")]
|
||||||
UnknownErrorType(String),
|
UnknownErrorType(String),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ impl UsbmuxdConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_pair_record(&mut self, udid: &str) -> Result<PairingFile, IdeviceError> {
|
pub async fn get_pair_record(&mut self, udid: &str) -> Result<PairingFile, IdeviceError> {
|
||||||
|
debug!("Getting pair record for {udid}");
|
||||||
let mut req = plist::Dictionary::new();
|
let mut req = plist::Dictionary::new();
|
||||||
req.insert("MessageType".into(), "ReadPairRecord".into());
|
req.insert("MessageType".into(), "ReadPairRecord".into());
|
||||||
req.insert("PairRecordID".into(), udid.into());
|
req.insert("PairRecordID".into(), udid.into());
|
||||||
@@ -192,6 +193,8 @@ impl UsbmuxdConnection {
|
|||||||
port: u16,
|
port: u16,
|
||||||
label: impl Into<String>,
|
label: impl Into<String>,
|
||||||
) -> Result<Idevice, IdeviceError> {
|
) -> Result<Idevice, IdeviceError> {
|
||||||
|
debug!("Connecting to device {device_id} on port {port}");
|
||||||
|
|
||||||
let mut req = plist::Dictionary::new();
|
let mut req = plist::Dictionary::new();
|
||||||
req.insert("MessageType".into(), "Connect".into());
|
req.insert("MessageType".into(), "Connect".into());
|
||||||
req.insert("DeviceID".into(), device_id.into());
|
req.insert("DeviceID".into(), device_id.into());
|
||||||
@@ -200,6 +203,10 @@ impl UsbmuxdConnection {
|
|||||||
match self.read_plist().await?.get("Number") {
|
match self.read_plist().await?.get("Number") {
|
||||||
Some(plist::Value::Integer(i)) => match i.as_unsigned() {
|
Some(plist::Value::Integer(i)) => match i.as_unsigned() {
|
||||||
Some(0) => Ok(Idevice::new(self.socket, label)),
|
Some(0) => Ok(Idevice::new(self.socket, label)),
|
||||||
|
Some(1) => Err(IdeviceError::UsbBadCommand),
|
||||||
|
Some(2) => Err(IdeviceError::UsbBadDevice),
|
||||||
|
Some(3) => Err(IdeviceError::UsbConnectionRefused),
|
||||||
|
Some(6) => Err(IdeviceError::UsbBadVersion),
|
||||||
_ => Err(IdeviceError::UnexpectedResponse),
|
_ => Err(IdeviceError::UnexpectedResponse),
|
||||||
},
|
},
|
||||||
_ => Err(IdeviceError::UnexpectedResponse),
|
_ => Err(IdeviceError::UnexpectedResponse),
|
||||||
@@ -232,6 +239,7 @@ impl UsbmuxdConnection {
|
|||||||
self.socket.read_exact(&mut body_buffer).await?;
|
self.socket.read_exact(&mut body_buffer).await?;
|
||||||
|
|
||||||
let res = plist::from_bytes(&body_buffer)?;
|
let res = plist::from_bytes(&body_buffer)?;
|
||||||
|
debug!("Read from muxer: {res:#?}");
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user