-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Libre 3 reports results in a different way: * The history reports are missing a column of unknown meaning. * The reading reports are missing custom comments and error values. The current workaround makes the Libre 3 results to look like the results for earlier models and is for demonstration and documentation purposes only. A better implementation would abstract the difference in reporting format into the drivers for each device.
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# SPDX-FileCopyrightText: © 2023 The glucometerutils Authors | ||
# SPDX-License-Identifier: MIT | ||
"""Driver for FreeStyle Libre 3 devices. | ||
Supported features: | ||
The same as the fslibre driver. | ||
Expected device path: /dev/hidraw9 or similar HID device. Optional when using | ||
HIDAPI. | ||
This driver is a shim on top of the fslibre driver, forcing encryption to be | ||
enabled for the session and normalizing the returned records. | ||
Further information on the device protocol can be found at | ||
https://protocols.glucometers.tech/abbott/freestyle-libre | ||
https://protocols.glucometers.tech/abbott/freestyle-libre-2 | ||
""" | ||
|
||
from collections.abc import Sequence | ||
from typing import Optional | ||
|
||
from glucometerutils.support import freestyle_libre | ||
|
||
|
||
class Device(freestyle_libre.LibreDevice): | ||
_MODEL_NAME = "FreeStyle Libre 3" | ||
|
||
def __init__(self, device_path: Optional[str]) -> None: | ||
super().__init__(0x3960, device_path, encoding="utf-8", encrypted=True) | ||
|
||
@staticmethod | ||
def _normalize_history_record(record: Sequence[str]) -> Sequence[str]: | ||
"""Overridden function as one of the unknown columns is missing.""" | ||
record.insert(10, "0") | ||
return record | ||
|
||
@staticmethod | ||
def _normalize_result_record(record: Sequence[str]) -> Sequence[str]: | ||
"""Overridden function as error values and custom comments are missing.""" | ||
record.insert(19, "0") | ||
record.insert(28, 0) | ||
if len(record) > 29: | ||
record = record[:29] + 6*["\"\""] + record[29:] | ||
return record |
This file contains 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