Skip to content

Don't fail a sensor over an event-log error while it is still active - #31

Merged
ps2 merged 1 commit into
mainfrom
fix/event-log-replace-latch
Oct 31, 2026
Merged

ps2 merged 1 commit into
mainfrom
fix/event-log-replace-latch

Conversation

@ps2

@ps2 ps2 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #29.

Bytes 0–6 of the Libre 3 patch status are the sensor's latest event-log entry, and they repeat until it logs another. An errorData code there while patchState is still active (4) is history, not the sensor's live state, but LibreLoop latched "Replace sensor" / "Sensor failed" on it until a new sensor was paired.

  • An error code from an active sensor now raises a soft, retractable Check sensor notice, as code 7 already did. It doesn't mark the sensor failed or inoperable, and readings keep reaching Loop.
  • Replace sensor needs the patch state to leave active. A sensor that stops sending glucose already shows signal loss.
  • The alerted event entry (attention@lifeCount.index) is persisted, so a relaunch or reconnect doesn't alert again for the same entry.
  • discardSensor() now clears sensorNeedsReplacement / sensorEndedNormally, so a new sensor doesn't show "Sensor failed" from its scan until it pairs (from the issue's related problems).

Testing

Unit tests: 16/16 pass. Three are new; testReplacementRecordsTheSensorEndOnce now uses a terminated patch state (6), since errorData 8 with an active sensor is the case this changes.

In the iOS Simulator against libre3sim:

Step Result
POST /event {"errorData":8} (patch state stays 4) sensor attention: checkSensor (rawAttention=replaceSensor, sensorError=terminated, patchState=active); "Check sensor" notice; readings keep forwarding; no Replace Sensor in the HUD
Dismiss, relaunch the app no alert again, no duplicate sensorIssue
POST /event {"errorData":0} sensor attention: none; notice retracted
POST /terminate {"errorData":8} (patch state 8) sensor attention: replaceSensor; "Replace sensor" alert and HUD status

Bytes 0-6 of patch status are the sensor's latest event-log entry, and they repeat
until it logs another. An error code there while the patch state is still active (4)
is history, not the sensor's live state: a Libre 3 Plus logged errorData 8 at minute
8083 and kept sending readings, but LibreLoop latched "Replace sensor" / "Sensor
failed" until a new sensor was paired (#29).

An error code from an active sensor now raises a soft, retractable "Check sensor"
notice, as code 7 already did. "Replace sensor" needs the patch state to leave active;
a sensor that stops sending glucose already shows signal loss. The alert's event entry
is persisted so the same entry doesn't alert again after a relaunch, and discarding a
sensor now clears its replacement state, so the next sensor doesn't show "Sensor
failed" from its scan until it pairs.

Fixes #29
@ps2
ps2 merged commit fafa679 into main Oct 31, 2026
@aidanlane

Copy link
Copy Markdown

Wow, that was quick, thanks @ps2!

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.

Replace Sensor" latched on a working Libre 3 Plus: stale event-log errorData 8 read as live sensor state

2 participants