Repository navigation
suunto_nautic: stream /Data on the handle its GET returned, and release handles - #8
Merged
Merged
Conversation
…se handles A GET of /Logbook/byId/<id>/<resource> binds the id to one of the resource's handle slots (00 24 <res>, or 10 24 <res> while the 00 slot is still bound) until a 0x0B release frees it. The driver subscribed to a hard-coded 00 24 0E and only ever released a hard-coded 00 24 12, so the /Data slot stayed bound to the first dive downloaded on a link: a later dive's GET got the 10 slot, and the subscription streamed the first dive's profile under the later dive's id. The listed-size check caught it as an incomplete download. Subscribe and unsubscribe on the handle from the GET's ACK with normal message ids, and release every per-id handle once its transfer is done (/Data after the stream stops, /Summary after the last page, a raw short fetch after its frame), as the Suunto app does. Static (F0) and unknown (FF) handles are left alone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 4, 2026
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.
Problem
Reported on deepsealabs/libdc-swift#29 (urbamax, Suunto Nautic). After downloading dive 1787752091 by id, a by-id download of 1788616918 on the same link came back with 1787752091's profile bytes. Only the listed-size check (#58) stopped it being saved as the wrong dive.
Root cause
A GET of
/Logbook/byId/<id>/<resource>binds that id to one of the resource's handle slots:00 24 <res>, or10 24 <res>while the 00 slot is still bound. The slot stays bound until a0x0Brelease. You can see this in the Suunto app capture (it alternates00 24 12/10 24 12and always releases the previous handle) and in urbamax's own extractor log (the second dive's/Dataresolved to10240e).The driver subscribed (
0x10) and unsubscribed (0x11) on a hard-coded00 24 0Eand released (0x0B) a hard-coded00 24 12, with message ids derived from ACK bytes. The/Dataslot was never released, so the first dive downloaded on a link kept00 24 0E. A later dive's GET got10 24 0E, but the driver still subscribed to00 24 0Eand streamed the first dive.Fix
/DataGET's ACK, using the normal sequence counter for message ids./Dataafter the stream stops (or is refused),/Summaryafter the last page, and a short fetch after its frame. Static (F0) and unknown (FF FF FF) handles are skipped. The release is best-effort, and its0x03reply is matched by message id.The first download on a fresh link is unchanged on the wire: the ACK handle is
00 24 0Ethere, same as the old hard-coded value.Tests
The libdc-swift fake watch now binds per-id slots and only frees them on
0x0B. That reproduces the bug against the old driver: by-id A then B returns A's bytes, and foreach of 2+ dives gets the wrong profile for later dives. Both pass with this change. Covered in the libdc-swift PR that bumps this submodule.🤖 Generated with Claude Code