wait more between tcp connect reply reads

This commit is contained in:
Vladan Popovic 2023-02-20 17:24:35 +01:00
parent 5e6810cae8
commit c9e80434fe
1 changed files with 5 additions and 3 deletions

View File

@ -280,13 +280,15 @@ impl<UART: serial::Uart, PWK: OutputPin, RST: OutputPin, PW: OutputPin> Modem<UA
pub fn tcp_connect(&mut self, addr: &str, port: u16) -> Result<()> {
let at_command = format!("AT+CIPSTART=\"TCP\",\"{}\",\"{}\"", addr, port);
let _ = self.send(&at_command, "CONNECT OK");
let mut reply_result = self.send(&at_command, "CONNECT OK");
for _ in 0..3 {
if let Ok(reply) = self.command_read_response(Some("CONNECT OK".to_string())) {
if let Ok(reply) = reply_result {
println!("TCP connect replied with {}", reply);
break
} else {
reply_result = self.command_read_response(Some("CONNECT OK".to_string()));
}
thread::sleep(Duration::from_millis(500));
thread::sleep(Duration::from_millis(1000));
}
Ok(())
}