Skip to content

Record Libre 3 sensor states and ends as CGM events - #19

Merged
ps2 merged 1 commit into
mainfrom
libre-sensor-state-events
Oct 12, 2026
Merged

ps2 merged 1 commit into
mainfrom
libre-sensor-state-events

Conversation

@ps2

@ps2 ps2 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Records Libre 3 sensor states as CGM events, like G7 (LoopKit/G7SensorKit#90) and G5/G6 (LoopKit/CGMBLEKit#224), using the sensorIssue type from LoopKit/LoopKit#637.

  • sensorIssue. The sensor's patch status arrives about once a minute. When what it reports as wrong changes, a sensorIssue is recorded with the sensor's own name for it in error.code: the error code (transmissionError, terminated, ...) or, without one, the attention it implies (checkSensor, ...). metadata keeps the raw errorData and patchState. isFatal is set only when LibreLoop shows the sensor as failed, so a normal end of wear isn't a failure.
  • sensorEnd. Recorded once, when the sensor needs replacing, rather than only when the user discards it. Discarding doesn't record a second one.
  • Dedup. The last state recorded is kept in the manager's persisted state, so a relaunch doesn't repeat it. A new pairing or discarding the sensor clears it.
  • Device identifier. Now the sensor serial alone. serial:receiverID gave one sensor several identifiers. A session that is running when this ships ends under a different identifier than it started with.

Tests: LibreLoopSensorStateEventTests (3).

The sensor's patch status, about once a minute, says when something is
wrong. When that changes, send Loop a sensorIssue with the sensor's own
name for it (its error code, or the attention it implies) and the raw
errorData and patchState. It is fatal only when LibreLoop shows the
sensor as failed, so a normal end of wear isn't recorded as a failure.
When the sensor needs replacing, its sensorEnd is sent then, once,
rather than only when the user discards it.

The last state sent is kept in the manager's persisted state, so a
relaunch doesn't repeat it, and is cleared by a new pairing.

The device identifier is now the sensor serial alone. Appending the
receiver ID gave the same sensor different identifiers.
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