Skip to content

Parse G7 glucose messages with a nonzero status - #88

Closed
ps2 wants to merge 1 commit into
mainfrom
g7-glucose-nonzero-status-main
Closed

ps2 wants to merge 1 commit into
mainfrom
g7-glucose-nonzero-status-main

Conversation

@ps2

@ps2 ps2 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Backport of the parsing fix from #85 to main, cherry-picked from d3f2a7b.

A failed sensor answers the glucose request with status 0x80, its last reading and algorithm state 27 (transmitterFailed). The parser rejected any nonzero status. So the manager logged "Unable to handle glucose control response" every five minutes, never learned the state, and showed the sensor as connecting instead of raising the sensor-failed alert.

The message now keeps the status and decodes the timestamp, sequence, age and algorithm state for any status. Glucose, prediction and trend are nil when the status is nonzero, so a reading the sensor didn't mark current is never stored. On main, G7CGMManager.sensor(_:didRead:) checks algorithmState.sensorFailed before it looks at glucose, so the alert fires as on next-dev.

Not included

#85's other three commits (asking for the transmitter version until the serial number arrives, and sending the serial with the sensor start) depend on next-dev-only code: the transmitter version query, G7SensorRecord, and the previous-sensor page. They aren't part of this backport.

Testing

Adds testFailedSensorStatusStillReportsAlgorithmState to G7GlucoseMessageTests. The same change and test pass on next-dev. I couldn't build the legacy workspace here: Xcode 27 rejects its watchOS 7.1/6.1 and TrueTime iOS 12 deployment targets before anything compiles.

A failed sensor answers the glucose request with status 0x80, its last
reading and algorithm state 27 (transmitterFailed). The parser rejected any
nonzero status, so the manager logged "Unable to handle glucose control
response" every five minutes, never learned the state, and showed the
sensor as connecting instead of raising the sensor-failed alert.

The message now keeps the status and decodes the timestamp, sequence, age
and algorithm state for any status. Glucose, prediction and trend are nil
when the status is nonzero, so a reading the sensor did not mark current is
never stored.
@ps2
ps2 requested review from Camji55 and marionbarker October 11, 2026 16:15
@ps2

ps2 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

This is not an important thing to fix for non-direct integration.

@ps2 ps2 closed this Oct 11, 2026
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