-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Omnipod DASH - adressing race condition on connection startup AAPS 3.3.2.1 Android 16 #4313
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
base: dev
Are you sure you want to change the base?
Omnipod DASH - adressing race condition on connection startup AAPS 3.3.2.1 Android 16 #4313
Conversation
… calls to onError()
| if (newState == BluetoothProfile.STATE_CONNECTED && status == BluetoothGatt.GATT_SUCCESS) { | ||
| connected.countDown() | ||
| aapsLogger.debug(LTag.PUMPBTCOMM, "OnConnectionStateChange delaying gattConnected event by $SLEEP_AFTER_CONNECT_GATT ms") | ||
| CoroutineScope(Dispatchers.Main).launch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dispatchers.Main is used for UI operation
change to Dispatchers.IO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MilosKozak Updated to Dispatchers.IO
|
|
Adding a hard-coded 1 second delay might cause the Pod to prematurely disconnect. If the Pod doesn't receive a Bluetooth operation with a certain amount of time it will automatically close the connection on it's own. So this 1 second delay might cause issues for other users on different phones. What would be better would be to implement a state machine logic where the call to the discover services function only happens after the encryption complete callback. Or maybe consider not calling the discover services function. Android internally calls it automatically and caches the results. To really understand this issue I think a gatt server log is needed instead of the AAPS logs to understand what is really going on under the hood. I can take a look at the gatt log if provided. I don't think I've seen this race condition before on any logs uploaded so far from people with Dash issues or on my Pixel 7 pro. |
|
@nickb24 I attached two gatt logs let me know if you need more processes. |
|
@vanmegen Sorry I wasn't more clear. The information that would be needed is a "Bluetooth HCI snoop log". To capture this you can follow the steps that Google support detailed in this example: https://issuetracker.google.com/issues/458048110#comment7 However, don't upload these logs publicly. It would contain personal information unless you scrub it first. |
The device 04:40 is a withings smartwatch
I did disable "Android Auto" at some point as it was showing up in the logs. but no difference, so I re-enabled it since. As a side note, I did try other changes as well:
|
I tried both, with and without bonding and had connectivity issues with both. With the delay from this PR, it works reliably with and without bonding. (Initially I bonded the pod, but my latest POD is not bonded anymore). |
Understood. I suggest this PR can be used for people to test, but shouldn't be put into the master branch as is. If this fixes issues for some people, then perhaps logic can be written so that this delay is only added after X failed connection attempts or after detecting the specific scenario race condition scenario. |
|
I noticed that after updating my Pixel 9 Pro XL to Android 16 QPR2 and running v3.3.2.1 without this PR, the issue (connecting -> handshaking -> connecting -> ....) is gone. Would be good if somebody else could also confirm this. |
Thanks for the tip! Seems that my Samsung Galaxy S22 Ultra does bot have this issue anymore either. Also using v3.3.2.1. Second pod in use without this nor any other issues. |





When I switched to my new Phone, a Google Pixel 10 Pro XL, I noticed that the Omnipod DASH did no longer work reliably.
The symptom was a cycle of
connecting -> handshaking -> connecting -> ....
Looking at system logs, I noticed:
Note that
BTA_GATTC_ENC_CMPL_CB_EVT = 17, /* encryption complete callback event */
I.e., the encryption completed log message comes after the bluetooth callback onConnectionStateChange has been called, causing the call to discoverServices() to happen when encryption has not been completely setup.
This PR changes the behavior such to add a small delay in the OnConnectionStateChange handler waiting 1 second so that encryption can complete before discover services is called.
Now, the logs show that there is a 1 second delay before discoverServices is called.
With this change, I did not have problems with my last 3 Pods.
Attached is an annotated log with this change:
2025-11-12 previous pod - with paring - sample-event17-delay - working.txt
Could someone with similar issues please verify