fw: reset packet parser after full packet received
This commit is contained in:
parent
1ab57fe316
commit
ea94072e42
@ -42,6 +42,8 @@ impl CommandInterface {
|
||||
(processed_bytes, res.ok())
|
||||
});
|
||||
|
||||
defmt::debug!("Received data");
|
||||
|
||||
// Check for socket errors
|
||||
let packet = match res {
|
||||
// We got a packet! unwrap it
|
||||
|
@ -89,8 +89,9 @@ fn main() -> ! {
|
||||
// Set a keepalive on the socket to handle unexpected client disconnects
|
||||
{
|
||||
let mut sock = socket_set.get_mut::<TcpSocket>(command_socket);
|
||||
sock.set_keep_alive(Some(Duration::from_secs(5)));
|
||||
sock.set_timeout(Some(Duration::from_secs(5)))
|
||||
// TODO these values are obscene, should fix the underlying bug
|
||||
sock.set_keep_alive(Some(Duration::from_secs(2)));
|
||||
sock.set_timeout(Some(Duration::from_secs(10)))
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,11 +194,13 @@ impl PacketParser {
|
||||
// Check CRC
|
||||
7 => {
|
||||
if self.crc.get_crc() == byte {
|
||||
return Ok(CommandPacket {
|
||||
let out = CommandPacket {
|
||||
is_write: self.is_write,
|
||||
setting: self.setting,
|
||||
value: self.value,
|
||||
});
|
||||
};
|
||||
self.reset();
|
||||
return Ok(out);
|
||||
} else {
|
||||
self.reset();
|
||||
return Err(Error::BadCrc);
|
||||
|
Loading…
Reference in New Issue
Block a user