try to fix reading and fail at it :/
This commit is contained in:
parent
31a6228669
commit
8308bdb9a0
2 changed files with 8 additions and 9 deletions
16
src/modem.rs
16
src/modem.rs
|
@ -125,12 +125,8 @@ impl<UART: serial::Uart> Modem<UART> {
|
|||
println!("-----------------------------------------------------------");
|
||||
println!("Sending {} ...", cmd.text);
|
||||
|
||||
let _ = self.serial
|
||||
.write_bytes(cmd.text.as_bytes())
|
||||
.map_err(|_| ModemError::SendDataError(format!("Error in send_command({})", cmd.text)))?;
|
||||
|
||||
let _ = self.serial
|
||||
.write(&['\r' as u8])
|
||||
let _ = nb::block!(self.serial
|
||||
.write_bytes(&[cmd.text.as_bytes(), &['\r' as u8]].concat()))
|
||||
.map_err(|_| ModemError::SendDataError(format!("Error in send_command({})", cmd.text)))?;
|
||||
|
||||
self.command_read_response(cmd.contains)
|
||||
|
@ -253,7 +249,7 @@ impl<UART: serial::Uart> Modem<UART> {
|
|||
pub fn tcp_connect(&mut self, addr: &str, port: u16) -> Result<()> {
|
||||
let _ = self.send_command(Command::tcp_connect(addr, port))?;
|
||||
for _ in 0..3 {
|
||||
if let Ok(reply) = self.command_read_response(Some("CONNECT_OK".to_string())) {
|
||||
if let Ok(reply) = self.command_read_response(Some("CONNECT OK".to_string())) {
|
||||
println!("TCP connect replied with {}", reply);
|
||||
break
|
||||
}
|
||||
|
@ -532,7 +528,11 @@ pub fn main<T: Sync + Send>(
|
|||
|
||||
let _ = mdm.tcp_set_quick_mode(false);
|
||||
let _ = mdm.tcp_set_manual_receive(true);
|
||||
let _ = mdm.tcp_connect("51.158.66.64", 7887)?;
|
||||
|
||||
if let Err(_) = mdm.tcp_connect("51.158.66.64", 7887) {
|
||||
continue;
|
||||
}
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
|
||||
let _ = mdm.mqtt_connect(device_id)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue