Trying to fix communication
Some checks failed
Midea Merge / Serial Reader (pull_request) Failing after 12m9s
Some checks failed
Midea Merge / Serial Reader (pull_request) Failing after 12m9s
This commit is contained in:
parent
b708a13b50
commit
2150e2b2b3
3 changed files with 20 additions and 13 deletions
|
@ -474,6 +474,7 @@ mod test {
|
||||||
use super::Cloud;
|
use super::Cloud;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[serial]
|
||||||
async fn reroute() -> Result<()> {
|
async fn reroute() -> Result<()> {
|
||||||
let mut cloud = Cloud::new("michaelh.95@t-online.de", "Hoda.semi1")?;
|
let mut cloud = Cloud::new("michaelh.95@t-online.de", "Hoda.semi1")?;
|
||||||
|
|
||||||
|
@ -483,6 +484,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[serial]
|
||||||
async fn login_id() -> Result<()> {
|
async fn login_id() -> Result<()> {
|
||||||
let mut cloud = Cloud::new("michaelh.95@t-online.de", "Hoda.semi1")?;
|
let mut cloud = Cloud::new("michaelh.95@t-online.de", "Hoda.semi1")?;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ pub trait RequestSerializer {
|
||||||
fn serialize(&self) -> Vec<u8>;
|
fn serialize(&self) -> Vec<u8>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct CommandRequest {
|
pub struct CommandRequest {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
|
|
|
@ -124,22 +124,24 @@ impl Device {
|
||||||
}
|
}
|
||||||
|
|
||||||
for cmd in cmds {
|
for cmd in cmds {
|
||||||
self.build_send(cmd)?;
|
'sending: loop {
|
||||||
|
self.build_send(cmd.clone())?;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut buf = [0; 512];
|
let mut buf = [0; 512];
|
||||||
let bytes_read = match self.socket.lock().unwrap().read(&mut buf) {
|
let bytes_read = match self.socket.lock().unwrap().read(&mut buf) {
|
||||||
Ok(b) => b,
|
Ok(b) => b,
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
if bytes_read == 0 {
|
if bytes_read == 0 {
|
||||||
bail!("socket error");
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.parse_message(&buf[..bytes_read])? {
|
match self.parse_message(&buf[..bytes_read])? {
|
||||||
ParseMessage::Success => break,
|
ParseMessage::Success => break 'sending,
|
||||||
ParseMessage::Padding => continue,
|
ParseMessage::Padding => continue,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,6 +254,7 @@ mod test {
|
||||||
use crate::{device::Device, devices::AttributeValue, Cloud, Startup};
|
use crate::{device::Device, devices::AttributeValue, Cloud, Startup};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[serial]
|
||||||
async fn verify_hex() -> Result<()> {
|
async fn verify_hex() -> Result<()> {
|
||||||
let devices = Startup::discover().await?;
|
let devices = Startup::discover().await?;
|
||||||
|
|
||||||
|
@ -272,6 +275,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[serial]
|
||||||
async fn connect_py_token() -> Result<()> {
|
async fn connect_py_token() -> Result<()> {
|
||||||
let devices = Startup::discover().await?;
|
let devices = Startup::discover().await?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue