Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rapid Reconnect Transition mode #3829

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Navid200
Copy link
Collaborator

@Navid200 Navid200 commented Dec 25, 2024

This PR makes the user experience with G7 and xDrip consistent regardless of the random nature caused by the G7 Rapid Reconnect function:

Problem After this PR
There is an 80% chance xDrip will miss the subsequent transmission to a pairing xDrip is guaranteed to capture the subsequent transmission to pairing
There is 80% chance that the next capture after pairing occurs in 6-9 minutes There is 80% chance that the next capture after pairing occurs in 1-4 minutes
An error message may be shown after pairing No error message will be shown after pairing
xDrip may miss the second transmission after pairing xDrip is guaranteed to capture the second transmission after pairing
There is 20% chance that xDrip will pair on the once every 5 minute time grid. Even then, xDrip may miss the second handshake after the pairing handshake. There is 20% chance xDrip will pair on the once every 5 minute time grid. xDrip is guaranteed to capture the second handshake after the pairing handshake.

What activates Rapid Reconnect Transition mode?
It is automatically activated when xDrip pairs with a G7.
I refer to this in the logs as the first Rapid Reconnect Transition mode handshake.


What happens in Rapid Reconnect Transition mode?
xDrip wakes once a minute.
The Hunting Transmitter note is shown on the Dex status page after pair approval until a subsequent handshake regardless of any event.
Subsequent to the pair request approval, after xDrip completes another handshake, scan always mode is activated.
No brain status error is shown on the Dex status page.


What disables Rapid Reconnect Transition mode?
When either one of the following two conditions is satisfied, the Rapid Reconnect Transition mode is disabled.

1- Two handshakes subsequent to the pair request approval handshake
2- 10 minutes after pair request approval


Could it fail?
If the user walks away from the phone after pairing before two subsequent handshakes, the intended process will not complete.
But, the user can just wait for xDrip to do its job. Alternatively, the user can forget the device from the Bluetooth list and temporarily change the transmitter ID and wait for a pair request for the Rapid Reconnect Transition mode to activate again.


Test

The following tests were performed on an Android 11 Motorola Stylus phone.
Before every test, xDrip was uninstalled and all devices starting with DXCM were deleted from the Bluetooth list.
Then, the version under test was installed. Then, xDrip battery optimization was disabled. After that, source wizard was used to choose G7, background location access was granted, and the pairing code was entered.

For both tests, the transmitter was disconnected more than 15 minutes prior and it was confirmed that it was transmitting once a minute.
For both tests, it was arranged for pairing to occur one 1-minute cycle before the 5-minute cycle transmission.
For both tests, collection was enabled about 30 seconds before the transmission cycle start.

Screens recordings in the following table are sped up by a factor of 16.

Before After
https://github.com/user-attachments/assets/0e8c0306-fb9f-44ff-bb81-918fc7b0651d https://github.com/user-attachments/assets/02a373ef-8c51-4f3c-a786-ecc06fd4c608
Before After

If the user waits patiently for several read cycles for xDrip to enable always scan mode, it will eventually discover the correct time grid.
The problem is that many users will intervene thinking that something is wrong considering the possibility of the error message and the longer periods of time with no connectivity. So, they restart the phone or restart collector etc. Sometimes, these will succeed.

The guide asks the user to read this: https://navid200.github.io/xDrip/docs/Dexcom/G7OnceAMinuteScan.html
If user follows those instructions, the outcome will be identical to what this PR does.
The problem is that you cannot expect everyone to read all the pages of the guide.
This PR does the right thing with no need for any human intervention other than keeping the old sensors away and staying with the phone for up to 10 minutes after pairing.

This PR ensures connectivity as fast as possible taking into account everything that could possibly go wrong.

@Navid200 Navid200 marked this pull request as draft December 26, 2024 18:18
@Navid200 Navid200 marked this pull request as ready for review January 8, 2025 02:21
@Navid200 Navid200 changed the title Rapid Reconnect Rapid Reconnect Transition mode Jan 14, 2025
@Navid200 Navid200 marked this pull request as draft January 15, 2025 13:20
@Navid200 Navid200 marked this pull request as ready for review January 16, 2025 02:20
@Navid200
Copy link
Collaborator Author

@jamorham I'm sorry about the long description.
You don't have to read the whole thing. Please just tell me what you think or if you have any question.

@Navid200
Copy link
Collaborator Author

Navid200 commented Jan 19, 2025

I cannot recreate the problem with my Pixel.

Edit:
That's not true. Using the same transmitter, my Pixel 6a also shows problems and can benefit from this PR.

I wanted to demonstrate the problem with an active device that was still younger than 10 days. But, it does not happen with every G7.

@jamorham
Copy link
Collaborator

Thanks for the very detailed PR. I will have to study it in some detail because making changes to the timing aspect is a very significant change which has to be handled really well. I appreciate there are some inconsistencies already and it is definitely worth a closer look to see if things can be improved but equally I don't find consistent behavior from the transmitter side which makes testing harder.

@Navid200
Copy link
Collaborator Author

@Navid200
Copy link
Collaborator Author

Navid200 commented Feb 1, 2025

Thanks for the very detailed PR. I will have to study it in some detail because making changes to the timing aspect is a very significant change which has to be handled really well. I appreciate there are some inconsistencies already and it is definitely worth a closer look to see if things can be improved but equally I don't find consistent behavior from the transmitter side which makes testing harder.

Thanks
This is a critical change and I appreciate a critical review.

I hope I have not misunderstood the comment about testing challenge.
I identify the timing of the transmitter and write it down. It could be something like: 00:02:50
This implies 00:07:50 as well as the time grid is cycles at 5 minutes.

Now that I have that, I know the rapid reconnect timings will be 00:3:50, 00:04:50, 00:05:50 and 00:06:50. Of course, there are another 4 at 00:08:50 ...
Having the rapid reconnect timings, I connect to the transmitter. Then, I disconnect from it and wait 15 minutes. This guarantees that it is in rapid reconnect mode. I can also verify using a scanner.

I install xDrip on the test phone and keep collection disabled during all scans. Each scan lasts about 17 seconds.
When I know there is no scan, I enable G7, and scan the QR code etc.
When xDrip is ready, I time enabling collection and the start of the test such that xDrip starts scanning 15 seconds before the start of the particular rapid reconnect slot I want to test.
I use the exact same slot for my before and after tests for a valid comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants