Skip to content

suunto_nautic: skip another app's subscription notifications in the /Data stream - #15

Open
trustthegoose wants to merge 1 commit into
deepsealabs:mainfrom
trustthegoose:nautic-skip-other-subscriptions
Open

trustthegoose wants to merge 1 commit into
deepsealabs:mainfrom
trustthegoose:nautic-skip-other-subscriptions

Conversation

@trustthegoose

Copy link
Copy Markdown

Part 1 of deepsealabs/libdc-swift#78, split out as requested because it affects stock build 22.

Problem

When the Suunto app is connected on the same phone, it holds subscriptions of its own, and the watch pushes their values over the shared link as 0x01 notifications with sequence number 0, the same opcode and sequence number as our /Data stream chunks. suunto_nautic_stream() takes every such packet as a chunk, so one of them fails the stream:

20:37:17.793 suunto_nautic_stream(): Unexpected chunk size (10).
20:37:18.120 suunto_nautic_download(): Retrying the stream of dive 1789487761.
20:37:22.895 suunto_nautic_stream(): Unexpected chunk size (10).

Both were the same notification, on another handle (Nautic, DC Tester build 22 on an iPad with the Suunto app connected):

A5 01 0A 00 | 00 00 | F0 BF 06 | 01 80 00 | 01 00 00 00 | crc

The watch also pushes that value to the app every 30 minutes, so the stray packet can turn up during any long download while the Suunto app is connected.

Fix

Skip a notification whose handle isn't the stream's. One wrinkle: compare the handle without its slot byte. Our stream's chunks carry the handle with slot F0, while the GET reply that bound it has slot 00 (e.g. chunks F0 24 0E for GET 00 24 0E); a full three-byte compare rejects every chunk of our own stream. The other subscription differs in the remaining two bytes (BF 06 vs 24 0E).

Testing

…Data stream

The Suunto app on the same phone holds subscriptions whose pushed values
arrive as 0x01 notifications with sequence number 0, like our stream
chunks (one seen on handle F0 BF 06 with a 4-byte payload). The stream
loop took them as chunks and failed the stream with "Unexpected chunk
size". Skip notifications whose handle isn't the stream's, comparing
without the slot byte (chunks carry slot F0, the GET reply slot 00).
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.

1 participant