Fix Colmi R03 heart-rate history sync (timezone offset in 0x15 request) - #107
Open
saksham2001 wants to merge 1 commit into
Open
Fix Colmi R03 heart-rate history sync (timezone offset in 0x15 request)#107saksham2001 wants to merge 1 commit into
saksham2001 wants to merge 1 commit into
Conversation
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
A user's R03 (firmware
RY03R_3.01.00_250611) pairs and syncs in PulseLoop but heart rate never appears, while QRing shows HR fine. Their diagnostics log shows clean connects, sync chains finishing in ~24s, zero errors — and zero HR data: the ring was replying to the HR-history stage with empty markers for every requested day.Root cause
The ring's RTC is set with plain local wall time (
setDateTime, no timezone), so its firmware keys HR-history days by local-time-as-UTC epochs. Both working reference implementations build the0x15request accordingly:YawellRingDeviceSupport.fetchHistoryHR):getTimeInMillis() + ZONE_OFFSET + DST_OFFSETcolmi_r02_client: midnight of the target date withtzinfo=UTCPulseLoop sent the true epoch of local midnight. On strict 3.x firmware the mismatched timestamp finds no day slot → empty reply, silently. HR is the only Colmi history stage whose request encodes a timestamp (activity/HRV use day indexes, stress takes none, SpO2/sleep/temp are big-data), which is why only HR failed.
Older-firmware rings (R02/R09/R11/R12 fleet) tolerate the mismatch — for west-of-UTC users the old timestamp still lands inside the correct ring-frame day — which is why this only surfaced now. The corrected form is byte-for-byte what QRing/GadgetBridge send to every model, so it cannot regress working rings.
Changes
ColmiEncoder.syncHeartRatenow takes the dayDateand addssecondsFromGMT(mirrors the JringmakeTimeSyncCommandidiom); contract documented at the byte layout.ColmiSyncEngine.requestHeartRate()passessyncDaydirectly.ColmiEncoderTests: +8 zone, DST-aware negative zone, GMT identity.Net behavioral change: 4 timestamp bytes in one request.
Testing
ColmiEncoderTests+ fullColmiDecoderTestssuite pass on the iOS simulator.