From ae4b95bed56569524d1c96d6790010adf10e7d0e Mon Sep 17 00:00:00 2001 From: JOE1994 Date: Sun, 18 Oct 2020 17:23:19 -0400 Subject: [PATCH] Don't give up when missing the initial transmit window --- rubble/src/link/connection.rs | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/rubble/src/link/connection.rs b/rubble/src/link/connection.rs index 25e52e62c..f0b857e42 100644 --- a/rubble/src/link/connection.rs +++ b/rubble/src/link/connection.rs @@ -349,13 +349,34 @@ impl Connection { }) } else { // Master did not transmit the first packet during this transmit window. + // Connection is not yet established. (4.5 Connection State) - // TODO: Move the transmit window forward by the `connInterval`. - // (do we also need to hop channels here?) - + let last_channel = self.channel; + self.hop_channel(); self.conn_event_count += Wrapping(1); - trace!("missed transmit window"); - Err(()) + trace!( + "DATA({}->{}): missed conn event #{}", + last_channel.index(), + self.channel.index(), + self.conn_event_count.0, + ); + + // TODO: return Err(()) when supervision timer exceeds 6 * connInterval. + // (4.5.2 Supervision timeout) + + return Ok(Cmd { + next_update: NextUpdate::At( + // Move the transmit window forward by the `connInterval`. + timer.now() + self.connection_interval(), + ), + radio: RadioCmd::ListenData { + channel: self.channel, + access_address: self.access_address, + crc_init: self.crc_init, + timeout: true, + }, + queued_work: false, + }); } }