Repository navigation
Merge dev into next-dev - #219
Merged
Merged
Conversation
…ation When the pod doesn't answer within the read timeout, readMessagePacket cancelled the connection straight from the PeripheralManager queue. The idle disconnect was moved off that queue in a715d9a because it raced CoreBluetooth's teardown and wedged the next connect; this call was missed. It also left commandConnectInFlight set, so the heartbeat probe didn't re-arm after the disconnect. Route it through disconnectOnDemand. Log the teardown and each peripheral configuration (duration, or the error naming the step that timed out) as device events. A failed configuration is ignored and the session's command then fails with notReady; the nil disconnects in #199 are this teardown, and these lines show where the time after a connect goes.
…s held Routing the teardown through disconnectOnDemand cleared commandConnectInFlight unconditionally, so with the app open (or a background Pod Keep Alive mode) the drop no longer took the keep-alive reconnect path and the link stayed down until the next command. Clear the flag only when the connection isn't held: a held link reconnects as before, and an idle one re-arms the probe. Also drop the comments saying a cancel from the PeripheralManager queue raced CoreBluetooth and wedged the next connect. There's no evidence for it, and the stuck-in-.connecting symptom is the InPlay link-layer wedge the eager watchdog handles. The calls still go through managerQueue because the connect-on-demand state lives there.
A cancel issued off managerQueue is suspected, without evidence, of wedging the next connect. Record each cancel's time and whether it ran on managerQueue, and when a connect sticks in .connecting (the eager watchdog fires, or an on-demand connect times out) log a [stuckConnect] device event with how long before it the last cancel ran and from which queue. The forceful reconnect in PeripheralManager.reconnect still cancels from the PeripheralManager queue, so field reports can compare the two.
…esponsive teardown in didDisconnect logStuckConnect read lastCancel asynchronously, so on the eager watchdog (already on managerQueue) the read ran after the watchdog's own cancel and always reported it. It now reads synchronously when called on managerQueue. disconnectUnresponsive no longer decides whether to keep commandConnectInFlight when it cancels. It marks the teardown, and didDisconnect clears the flag if the link isn't held at that moment. This closes the window where the app goes to the background between the cancel and didDisconnect while the failing command session is still counted: the flag stayed set and the probe didn't re-arm until the next command. Tag the unresponsive-pod and configuration device events.
The [stuckConnect] lines only existed to test whether a cancel from the PeripheralManager queue wedges the next connect. Nothing in the field reports points that way, so drop the bookkeeping and the comments that still asserted it. The managerQueue helpers stay because the connect-on-demand state lives there.
…er written sendMessagePacket marks a message as possibly received before writing its last packet. On Omnipod 5 a short message is a single packet, so a missing characteristic after a failed discovery threw notReady before anything was written, and the command was still recorded as unacknowledged. notReady is only thrown before a write is issued, so treat it as unsent: the session gets a certain failure and no pending command to resolve.
…d disconnect The device log couldn't say why the first exchange after a connect failed in #199. Setup and login errors were swallowed, and a disconnect didn't say who closed the link or what was in progress. - [connect] configured in Ns, with each step's time (services, characteristics, write size, hello, notifications, login), or configuration failed after Ns, with the error and the failing step. Login errors now reach this line instead of being logged only to os_log. Setup skipped on a fresh connection is logged too. - [send] and [read] on a failed exchange: the error, the stage (CTS, packet i/n, data seq N, ...), whether the message was sent, what was done about it, the peripheral and central state, whether the characteristics are present, and the time since connect. - [disconnect] on every disconnect: the error domain and code, or for our own cancels the reason (idle, unresponsive pod, background, watchdog, ...), with the time since connect, the phase (connect, setup, session name, idle) and the setup outcome. - The retry after a dropped link says how setup went. This replaces the [connectOnDemand] no response from pod line.
A pod that hangs up during a command, with the connection not held, left commandConnectInFlight set: readMessagePacket saw the link already down and skipped disconnectUnresponsive, so handleDisconnect took the idle path with the flag still set and didn't arm the probe, and the idle disconnect that would clear it needs a connected peripheral. With a network CGM in the background nothing else issues a command, so the heartbeat stopped. handleDisconnect's decision now lives in DisconnectPolicy, which has no CoreBluetooth dependency and is unit tested. A drop outside a command session clears the flag. A drop during one leaves it to the session, which may retry its connect, and when the last session ends with an unheld link down, the flag is cleared and the probe armed. That replaces unresponsiveTeardownPending, and keeps a cancelled probe's disconnect, which can arrive after a command connect has started, from clearing the flag under that connect. Two device-log fixes: a connect that timed out was logged as a setup failure at services, and a link iOS restored at launch was reported as not connected.
…nect-queue Log each connect's setup and every failed exchange and disconnect; don't mark unsent commands unacknowledged
* Unhook a replaced or forgotten PeripheralManager from BlePodComms BlePodComms set itself as the delegate of each PeripheralManager it adopted but never cleared it, so a pod's old manager (a pairing candidate that lost out, or a pod that was forgotten) could still finish a queued connect and call completeConfiguration(for:) on its own queue while self.manager pointed at another manager. Session setup then ran against self.manager and tripped its dispatchPrecondition. Fixes #132 * Log in on the manager whose connect finished, and only for the current pod Clearing a replaced manager's delegate stops new callbacks, but one that has already started can still wait out the O5 write-size poll or podStateLock while self.manager changes, and establishSession then built the session on self.manager and trapped in sendMessagePacket. The session is now established on the manager passed in, so it always runs on that manager's queue, and completeConfiguration skips login when that manager is no longer the pod's. Both skips are noted in the connect's setup log, so a connect without a login no longer reads as setup ok with no login step.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings two
devchanges intonext-dev:DisconnectPolicy.The merge has no conflicts. c79c2d7 was already recorded on
next-devby #215, so nothing fromnext-devis reverted. The merged tree is identical to the build smoke-tested in the iOS Simulator against the pod simulator. That test covered a cold launch, a relaunch, two pod swaps in one app process, and background heartbeat cycles; every connect logged in and every command went through.OmniTests: 218 run, 3 skipped, 0 failures.
Please merge with "Create a merge commit".