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

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

wants to merge 1 commit into from

Conversation

JOE1994
Copy link
Contributor

@JOE1994 JOE1994 commented Oct 18, 2020

Hello 🦀 , this PR aims to close #77.

In the example from bluetooth specs (5.2) where the master misses the initial transmit window, the slave hops to a new channel for the next connection event. So I followed the example, to hop channels when the master device misses the initial transmit window.
image

Thank you for reviewing this PR ! 😸

Copy link
Owner

@jonas-schievink jonas-schievink left a comment

Choose a reason for hiding this comment

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

Looks correct, thanks!

Did you manage to test this, by chance?

@@ -57,6 +57,9 @@ pub struct Connection<C: Config> {
/// Contains the *instant* at which it should be applied to the Link Layer state.
update_data: Option<LlcpUpdate>,

/// 'transmitWindowSize' of current connection.
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
/// 'transmitWindowSize' of current connection.
/// `transmitWindowSize` of current connection.

@JOE1994
Copy link
Contributor Author

JOE1994 commented Oct 19, 2020

Looks correct, thanks!

Did you manage to test this, by chance?

I haven't yet tested it on hardware,
but I can try testing once I receive the nRF52840 board I ordered a few days ago :)

p.s.
I found a weird mistake I made in this PR:
I pushed the transmit window by (connInterval - win_size) and not by connInterval.. 🤷
I'll add a follow-up fix commit right away :)

@JOE1994
Copy link
Contributor Author

JOE1994 commented Oct 19, 2020

I made a force-push to squash the follow-up fix with the previous commit.

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.

@JOE1994 JOE1994 closed this by deleting the head repository Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't give up when missing the initial transmit window
2 participants