Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Don't give up when missing the initial transmit window #155

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions rubble/src/link/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,34 @@ impl<C: Config> Connection<C> {
})
} 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(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so I think if this fetches the current time via timer.now() this will cause the window to shift slightly each time it is missed. Instead, we should set the timer to expire at the previous update time plus the connection interval. This will always shift the window by the connInterval.

Note that the first update time has an additional 500 µs added to account for imprecisions, so that has to be accounted for. I guess we'll have to store it in the Connection after all.

),
radio: RadioCmd::ListenData {
channel: self.channel,
access_address: self.access_address,
crc_init: self.crc_init,
timeout: true,
},
queued_work: false,
});
}
}

Expand Down