diff --git a/src/modem.rs b/src/modem.rs index c040bf3..41d95ec 100644 --- a/src/modem.rs +++ b/src/modem.rs @@ -280,13 +280,15 @@ impl Modem 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(()) }