From ff779d0dc34c501911834818f151e22e20ec8a53 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sun, 12 Feb 2023 11:59:33 +0100 Subject: [PATCH] clear RX before sending AT commands --- src/modem.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modem.rs b/src/modem.rs index 788bf39..6018de2 100644 --- a/src/modem.rs +++ b/src/modem.rs @@ -290,6 +290,8 @@ impl Modem { } pub fn tcp_manual_send(&mut self, buf: &[u8]) -> Result<()> { + thread::sleep(Duration::from_millis(200)); + self.serial.clear(); self.tcp_manual_send_data(buf) .map(|_| ()) } @@ -556,8 +558,6 @@ where )?; } if let Ok(()) = mdm.try_connect_gprs() { - let device_id = "c36a72df-5bd6-4f9b-995d-059433bc3267"; - // When command AT+CIPQSEND=0, it is in normal sending mode. In this mode, after user // sends data by AT+CIPSEND, if the server receives TCP data, it will give ACK message // to module, and the module will respond SEND OK. @@ -571,9 +571,8 @@ where continue; } } - thread::sleep(Duration::from_millis(500)); - mdm.serial.clear(); + let device_id = "c36a72df-5bd6-4f9b-995d-059433bc3267"; let _ = mdm.mqtt_connect(device_id)?; println!("entering queue receive loop ...");