Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Dexcom BG readings fail to upload to Nightscout due to non-unique _id field #280

Closed
LiroyvH opened this issue Oct 25, 2023 · 21 comments

Comments

@LiroyvH
Copy link
Contributor

LiroyvH commented Oct 25, 2023

My environment: Dexcom G6 (Anubis), iPhone 13 Mini with iOS 17.1, iAPS-dev, Nightscout self-hosted on private server.

- Problem:
I, seemingly out of the blue, started encountering issues with iAPS no longer being able to send glucose values ("entries") to Nightscout. Treatments and manual BG entries work fine, openAPS info works fine, but sending glucose values results, according to iAPS's logfiles, in a 500 Internal Server Error. Other apps, such as xDrip4iOS, would have no problem at all uploading glucose values; so a problem with Nightscout itself appeared to be ruled out. Several users reported this issue with iAPS, though only a very small fraction.

- Digging & Potential solution:
Upon further inspection (a packet capture (tcpdump) + analyzing it), it turns out the 500 error by Nightscout included a note containing the exact error triggering the Error 500. It appears that MongoDB threw an error "11000", which means: "Trying to write a value/index that is not unique". The only field in the "entries" collection that must be unique is the _id field, meaning somehow the exact same _id already existed in the database and thus Mongo rejected to insert our entry.

iAPS generates the ID for Dexcom G6 as follows:

_id: newGlucoseSample.syncIdentifier,
which results in <Dexcom TransmitterID> + <a 6-digit number> being set for the _id, eg: "8ABCDE 123456". Apparently this 6-digit number isn't always unique, at least not in some scenarios (see below), to the TransmitterID. What I did was replace that line (156) to read: _id: UUID().uuidString, instead to ensure it's random and unique.

- (partial) Victory: Nightscout uploads of BG entries are now working again!
The _id value appears to be unique again and Mongo accepts them.
However, something still isn't right as I still see "internal server error" scrolling by in the logs, but Nightscout is being updated. (And no, I killed any other app talking to Nightscout and I confirmed the values come from iAPS. :P) So what I did isn't the final solution, it just fixed it at one location. (I did notice in my packet traces (tcpdump) that iAPS sent the values twice. I thought it was just trying again because it got an error back, but maybe it always does it and 1 out of the 2 is now succeeding due to my code changes whilst the other still fails. I haven't got the time to debug that now; but can re-analyse traffic later if needs be. Not sure why it would send the "entries" value twice if it's not in error condition.)

- Potential causes & conditions to trigger it:
During troubleshooting this issue and sending a flood of my thoughts on Discord to brainstorm, @bjornoleh asked whether or not the DexcomG6 might have a 6-digit number with each reading. I'm not sure if it does - but it did point me to the DexcomSourceG6.swift file, where I found the ID being set in a different way than in BloodGlucose.swift.

If the Dexcom, or something related to it, indeed generates 6-digit unique ID's, then this will lead to non-unique ID's in the following situations:
1.) Anubis users whom reset their Anubis may get the same ID's being used again. Their Transmitter ID will also not be unique, so the _id field subsequently isn't unique and Nightscout starts rejecting entries. (Or well, Mongo is.) The same goes for users whom are still using G5's or very old pre-Firefly G6 transmitters that have reset capability.
2.) Dexcom has recently started to recycle Transmitter ID's, so it could happen that other non-Anubis users eventually run in to this as well.

Whatever the cause, the _id field is for some reason not unique whilst it should be, but changing the code the way I did solved the main problem and consistently and continuously made Nightscout integration work completely again instead of only treatments. I, however, don't know if this is the best or permanent solution - especially not as I still see "Internal Server Error" in the logs whilst entries are being uploaded. Hence opening an issue for tracking rather than submitting this code as "the fix". (Note: G5, G6, G7 and by the looks of it something in HealthKit may all be using non-unique _id's under certain conditions as they share the same code.).

@LiroyvH
Copy link
Contributor Author

LiroyvH commented Oct 26, 2023

Update:
I ran another tcpdump and analyzed the traffic to see why, despite successful uploads to Nightscout, I'm still seeing Internal Server Errors (500) in the logs.

It turns out that iAPS is attempting to backfill all the old readings, including the ones with a non-unique _id, to Nightscout; which thus fails with an Internal Server Error for obvious reasons. By the looks of it, iAPS is then treating the upload as having failed completely, including the values that actually made it to Nightscout just fine, rather than only partially. By the looks of it, it is now also trying to re-upload readings that were actually accepted by Nightscout. (Which of course are then rejected on the next attempt because they already exist because they've already been inserted successfully. :X)

So in order to get a fully working solution here, we must likely:
1.) Implement the code changes described above for G5, G6, G7 and any other place generating potentially non-unique ID's
2.) Don't upload old-style ID's to Nightscout OR Expunge, one-time, all pending uploads to Nightscout from before these code changes, so on first run of a new version containing these changes. (Or simply expunge them when encountering a 500. I dunno what the best solution is, but it must be done - iAPS must stop trying to send the non-unique readings to Nightscout.) By the looks of it, it seems to be storing them in "glucose.json". Or at least, the values there seem quite similar to what it's attempting to upload. (It has 284 entries vs +/- 200 I saw it attempted to upload.)

I could PR 1 if you wish, but I cannot PR 2 as I have no idea how to achieve that on first run of new version.

That should sort it once and for all for everyone. :)

@LiroyvH
Copy link
Contributor Author

LiroyvH commented Oct 27, 2023

PR to make the _id field unique is here: #285
The fix for the issue where, if someone has already ran in to this issue, the problem keeps occurring due to a logic flaw in the Nightscout handling is not included in that PR and still needs a fix.

avouspierre added a commit that referenced this issue Oct 28, 2023
Fix #280 with checking the compliance of ID as uuid. Not perfect (lost data in NS) but avoid the 500 error.
Fix for G7 sensor.
@avouspierre
Copy link
Collaborator

Fix blood glucose with a ID not compliance with UUID. Avoid to have a internat server error with NS but data are not uploaded.

@LiroyvH
Copy link
Contributor Author

LiroyvH commented Oct 28, 2023

@avouspierre Just to be sure, this stops the uploading of any value with a non-compliant/potentially non-unique _id to Nightscout? (I'm not sure what the "100" is referring to, so just checking as in theory you can have up to 288 I suppose).

@avouspierre
Copy link
Collaborator

@LiroyvH probably you saw the 100 in the code without analyzing the context of this value ☺️. IAPS splits the array of BG in a json inputs of 100 values to send to NS via post URL call. So all BG values are sent in 3 calls to NS.

@LiroyvH
Copy link
Contributor Author

LiroyvH commented Oct 30, 2023

@avouspierre Yup, I'm not so good with Swift (or any coding language for that matter :P) so a bit difficult to see/find context sometimes. Thanks for explaining! :) I think that should work fine to remedy the problem then. :)

@JohnKitching
Copy link

JohnKitching commented Nov 1, 2023

I'm seeing this with a Libre2 direct too.
I've stopped paying for NS so I assumed it was the end of my service but carbs, insulin etc are still being uploaded.

@antoinekh
Copy link

I'm seeing this with a Libre2 direct too. I've stopped paying for NS so I assumed it was the end of my service but carbs, insulin etc are still being uploaded.

Same with libre2

@LiroyvH
Copy link
Contributor Author

LiroyvH commented Nov 1, 2023

@JohnKitching @antoinekh Pls check iAPS logs (grep for Nightscout) and let me know what the error is, if any.

Are you both using paid services that you recently cancelled? Also what NS version?

@JohnKitching
Copy link

JohnKitching commented Nov 2, 2023

NS 14.2.6 (via T1Pal)

I've got a few of these:
2023-11-02T07:47:43+0000 [Nightscout] NightscoutManager.swift - uploadTreatments(_:fileToSave:) - 665 - DEV: The network connection was lost.

and a few of these:
2023-11-02T00:04:16+0000 [Nightscout] NightscoutManager.swift - uploadTreatments(_:fileToSave:) - 663 - DEV: Treatments uploaded
but BG isn't in NS

@antoinekh
Copy link

Nightscout version 14.2.4
Selfhosted on fly.io
https://antoinegcm.fly.dev/

2023-11-02T07:00:59+0100 [Nightscout] FetchTreatmentsManager.swift - subscribe() - 27 - DEV: Start fetching carbs and temptargets
2023-11-02T07:00:59+0100 [Nightscout] NightscoutManager.swift - uploadTreatments(:fileToSave:) - 665 - DEV: The network connection was lost.
2023-11-02T07:00:59+0100 [Nightscout] FetchGlucoseManager.swift - subscribe() - 183 - DEV: FetchGlucoseManager callback sensor
2023-11-02T07:01:57+0100 [Nightscout] FetchGlucoseManager.swift - subscribe() - 178 - DEV: FetchGlucoseManager timer heartbeat
2023-11-02T07:01:57+0100 [Nightscout] FetchTreatmentsManager.swift - subscribe() - 26 - DEV: FetchTreatmentsManager heartbeat
2023-11-02T07:01:57+0100 [Nightscout] FetchTreatmentsManager.swift - subscribe() - 27 - DEV: Start fetching carbs and temptargets
2023-11-02T07:01:59+0100 [Nightscout] FetchGlucoseManager.swift - subscribe() - 183 - DEV: FetchGlucoseManager callback sensor
2023-11-02T07:03:04+0100 [Nightscout] FetchGlucoseManager.swift - subscribe() - 183 - DEV: FetchGlucoseManager callback sensor
2023-11-02T07:03:07+0100 [Nightscout] NightscoutManager.swift - uploadGlucose(
:fileToSave:) - 633 - DEV: Glucose uploaded
2023-11-02T07:03:14+0100 [Nightscout] NightscoutManager.swift - uploadStatus() - 410 - DEV: Status uploaded
2023-11-02T07:03:14+0100 [Nightscout] NightscoutManager.swift - uploadStatus() - 410 - DEV: Status uploaded
2023-11-02T07:03:15+0100 [Nightscout] NightscoutManager.swift - uploadTreatments(:fileToSave:) - 663 - DEV: Treatments uploaded
2023-11-02T07:03:59+0100 [Nightscout] FetchGlucoseManager.swift - subscribe() - 178 - DEV: FetchGlucoseManager timer heartbeat
2023-11-02T07:03:59+0100 [Nightscout] FetchTreatmentsManager.swift - subscribe() - 26 - DEV: FetchTreatmentsManager heartbeat
2023-11-02T07:03:59+0100 [Nightscout] FetchTreatmentsManager.swift - subscribe() - 27 - DEV: Start fetching carbs and temptargets
2023-11-02T07:04:58+0100 [Nightscout] NightscoutManager.swift - uploadTreatments(
:fileToSave:) - 665 - DEV: The network connection was lost.
2023-11-02T07:05:07+0100 [Nightscout] FetchGlucoseManager.swift - subscribe() - 178 - DEV: FetchGlucoseManager timer heartbeat
2023-11-02T07:05:07+0100 [Nightscout] FetchTreatmentsManager.swift - subscribe() - 26 - DEV: FetchTreatmentsManager heartbeat
2023-11-02T07:05:07+0100 [Nightscout] FetchTreatmentsManager.swift - subscribe() - 27 - DEV: Start fetching carbs and temptargets
2023-11-02T07:05:07+0100 [Nightscout] FetchGlucoseManager.swift - subscribe() - 183 - DEV: FetchGlucoseManager callback sensor
2023-11-02T07:05:34+0100 [Nightscout] NightscoutManager.swift - uploadTreatments(_:fileToSave:) - 663 - DEV: Treatments uploaded
2023-11-02T07:06:08+0100 [Nightscout] FetchGlucoseManager.swift - subscribe() - 178 - DEV: FetchGlucoseManager timer heartbeat
2023-11-02T07:06:08+0100 [Nightscout] FetchTreatmentsManager.swift - subscribe() - 26 - DEV: FetchTreatmentsManager heartbeat
2023-11-02T07:06:08+0100 [Nightscout] FetchTreatmentsManager.swift - subscribe() - 27 - DEV: Start fetching carbs and temptargets
2023-11-02T07:06:08+0100 [Nightscout] FetchGlucoseManager.swift - subscribe() - 183 - DEV: FetchGlucoseManager callback sensor

@LiroyvH
Copy link
Contributor Author

LiroyvH commented Nov 3, 2023

@JohnKitching You don't see any "Glucose uploaded"? Only the network connection loss?

@antoinekh
According to that log:
2023-11-02T07:03:07+0100 [Nightscout] NightscoutManager.swift - uploadGlucose(:fileToSave:) - 633 - DEV: Glucose uploaded

So that looks like it was functioning OK to send glucose values. You don't see any?
I do see you also have multiple of the "network connection lost" errors. I've seen them in mine as well (local server at home, even works with internet down when at home :P), maybe I should look in to those a bit more sometime as I couldn't imagine it losing connection. Maybe a time-out that triggers too quickly.

@antoinekh
Copy link

@LiroyvH No nothing on nightscout, as you can see https://antoinegcm.fly.dev/
I have tried also to remove all nightscout data, but still the same, Insulin and Carbs ok but no Insulin

@LiroyvH
Copy link
Contributor Author

LiroyvH commented Nov 3, 2023

@antoinekh Are you 100% sure this is not a (Mongo-)storage or other resource issue over at Fly? (Eg: storage full). Because Nightscout is accepting your values judging by your logs, it just doesn't seem to write them.

@antoinekh
Copy link

@antoinekh Are you 100% sure this is not a (Mongo-)storage or other resource issue over at Fly? (Eg: storage full). Because Nightscout is accepting your values judging by your logs, it just doesn't seem to write them.

Yes I am sure as I can still write some other data to nightscout (Carbs and Insulin).
Data size is only full at 12%.

I have removed all the data to be sure

@JohnKitching
Copy link

JohnKitching commented Nov 3, 2023 via email

@LiroyvH
Copy link
Contributor Author

LiroyvH commented Nov 3, 2023

@antoinekh that's some weird shit right there haha.
Can you show me the glucose.json and uploaded-glucose.json? You can replace your BG values and any identifying information with random garbage if you wish. Please put them in a code view or quote. (3 backticks ` at start and end).

@JohnKitching Ok, so the exact same error.

Question to you both @antoinekh @JohnKitching Which version/branch are you sporting? Thanks

@LiroyvH
Copy link
Contributor Author

LiroyvH commented Nov 3, 2023

@antoinekh @JohnKitching Nevermind, I think I see the problem now.
Pushed potential fix to dev branch #300. (Not merged yet)

@antoinekh
Copy link

@antoinekh @JohnKitching Nevermind, I think I see the problem now. Pushed potential fix to dev branch #300. (Not merged yet)

Does this will fix previous glucose data?

@LiroyvH
Copy link
Contributor Author

LiroyvH commented Nov 3, 2023

@antoinekh No I don't think it will. At best it would only have synced the past 24 hours anyway - sorry.

@antoinekh
Copy link

@LiroyvH I just tested the last dev and this fix the issue, thanks a lot !

@LiroyvH LiroyvH changed the title Dexcom BG readings fail to upload to Nightscout due to seemingly non-unique _id field [BUG] Dexcom BG readings fail to upload to Nightscout due to non-unique _id field Nov 8, 2023
@LiroyvH LiroyvH changed the title [BUG] Dexcom BG readings fail to upload to Nightscout due to non-unique _id field [Bug] Dexcom BG readings fail to upload to Nightscout due to non-unique _id field Nov 8, 2023
@Jon-b-m Jon-b-m closed this as completed Nov 10, 2023
MikePlante1 added a commit to MikePlante1/iAPS that referenced this issue Nov 14, 2023
* Sync translated strings

* Clarify label

(cherry picked from commit 344f359a91a677c522a7116068029a9f401f1422)

* Calender Events
* Get IOB and COB for Calender events from CoreData.
* If loop older than 15 minutes display a 🚫

* Respectg Max Bolus setting when adding insulin.
Diable buttons when over Max Bolus.
Use Max Bolus also for adding insulin wihout bolusing

(cherry picked from commit cbeb5a08db0061a0518a9a3c6037300e0aa346d6)

* 😵

(cherry picked from commit 91d4fc79e70985e608287493b28336b97b44a49d)

* Update APSManager.swift

Spelling: succeded -> succeeded

* Update Bolus Alerts.
Allow 3 X Max Bolus for non-pump insulin,
but add alert when over Max Bolus.
Localize (tested in Swedish)

* Crowdin updates (Artificial-Pancreas#224)

* Minutes ago fix for G7 sensors.

(cherry picked from commit 0605328a02dd4598770fadafff4f566b6b8f5174)

* Dutch (Artificial-Pancreas#230)

* Change permissions required for calendar in iOS 17+ (Artificial-Pancreas#234)

* Change permissions required for calendar in iOS 17+

* Fix compile issue in Xcode 14 (Artificial-Pancreas#235)

* Improve the update of the date of Glucose View Header.

* Import Profile Settings from Nightcsout (Artificial-Pancreas#238)

Import Basal settings, carb ratios, sensitivities and glucose targets from Nightscout manually when tapping "Import Settings from Nightcsout"in the iAPS Nightscout settings. 

co-author @dnzxy

* Clean

* Face-ID for import

(cherry picked from commit c31995dd5635b106b56adffae359125bd4fb5624)

* Revert "Face-ID for import"

This reverts commit ff36ad3.

* Import DIA from NS.

(cherry picked from commit a6d9fa4dbd7e678fcea1b9bf2a542d56f914206b)

* Oops. Bad typo!

* Save Autotuned basal rates as normal basal rates and to pump.

* Button in Autotune settings. Hidden at the very bottom.

* Hard limit of 55 for insulinPeakTime
to avoid endless logs and errors in oref0

* adjust min/max insulinPeakTime depending on type of insulin.

* Save imported settings also to pump (basals).

(cherry picked from commit 7fc8aa56d0b31374ef6b1671ee7353fbbc784b0c)

* Update error message etc.

* Import errors

(cherry picked from commit 207f6e7508a789f6c51799ad7809ecf7ddf6a3ba)

* Localize Autotune settings

* Upload preferences and settings.

* Upload preferences when changed or when tapping button.
* Upload the iAPS specific settings when changed or when tapping button (FreeAPSSettings).
* Fix to only upload the profiles, settings and preferences when actually changed and not every time you exit settings.

* Clean

* New Crowdin updates (Artificial-Pancreas#246)

* Make button prominent

(cherry picked from commit ceb34e4b1561e12610aa3200d2bca90d483f3d24)

* New strings

* Validate also CR and ISF on import. Don't allow 0 or lower vallues

(cherry picked from commit aecd32067559c21a0f34cb63e221b9c4e0afde99)

* Don't allow DIA of 0 or lower

* More logging

* Allow DASH pumps to have 0U/h basal entries upon import, but total basal insulin (24h) still needs to be over 0U.
Don't allow other pumps to have 0U/h entries upon import.

* Fix healthkit issue for Insulin treatment

Fix the healthKit sync when stopped before the end Artificial-Pancreas#231
Fix the 0U basal in healthKit Artificial-Pancreas#149

* Add carbs shortcuts

Add shortcuts to add carbs with a specific date and fat/protein information.

* Update Crowdin configuration file

* New missing strings G7

* Merge pull request Artificial-Pancreas#252 from Artificial-Pancreas/crowdin_generated

New Crowdin updates

* ISSUE-257 | Fix typo in 'Last loop was more than' message

* Allow looping when HIGH (Artificial-Pancreas#259)

**Allow looping when HIGH**

* Allow lflat glucose when CGM readings are HIGH (but disable SM and high temps) for IOB computations etc.
* Display HIGH when CGM reading is HIGH.
* Display real glucose when entering capillary glucose.
* Allow (capillary readings over HIGH for normal looping.
* Display in Enacted pop-up.
* Display warning in same pop-up
* Disable SMB and high temps in oref2 code when reading is HIGH (potential invalid CGM reading).

* Manual glucose updates (Artificial-Pancreas#261)

* Display manual glucose entries in iAPS similar to Nightscout and xDrip.
* Upload to NIghtscout when created.
* Delete from Nightcsout when deleted in iAPS.
* Change colour of FPUs to work with the Nightscout format of manual glucose entries.
* Remove amounts of carb equivalents in Chart to make view less busy. This is a temporary fix until removed entirely when we have Fat and Protein models instead. 
* Make pop-up for new glucose cleaner and more prominent. Using both layers and shadow. This is a work in progress and in the future the oref0 info alerts will be replaced with same pop-ups, with images and charts etc. 
* Make glucose data table cleaner. Remove IDs and add when manual instead.

* Fix rounding issue with manaul glucose entries.

* Add missing localization for G7 Manager

* Save  Manual Glucose entries to Health

(cherry picked from commit e02f4bc3d84c00c5b3674b6b901e93ab1cae62d4)

* Add string

(cherry picked from commit a261b6a0f6f4a6fe4c403e21255f7c42a555dced)

* New translations localizable.strings (Dutch)

* New translations localizable.strings (French)

* New translations localizable.strings (Spanish)

* New translations localizable.strings (Arabic)

* New translations localizable.strings (Danish)

* New translations localizable.strings (German)

* New translations localizable.strings (Finnish)

* New translations localizable.strings (Hebrew)

* New translations localizable.strings (Italian)

* New translations localizable.strings (Polish)

* New translations localizable.strings (Portuguese)

* New translations localizable.strings (Russian)

* New translations localizable.strings (Slovak)

* New translations localizable.strings (Swedish)

* New translations localizable.strings (Turkish)

* New translations localizable.strings (Ukrainian)

* New translations localizable.strings (Chinese Simplified)

* New translations localizable.strings (Portuguese, Brazilian)

* New translations localizable.strings (Norwegian Bokmal)

* Manual Glucose.
Use rounded corners (after feedback)

* New translations localizable.strings (Norwegian Bokmal)

* New translations localizable.strings (Dutch)

* New translations localizable.strings (Russian)

* New translations localizable.strings (Russian)

* Dexcom G7 SAGE

Upload activation and session start date to NS.

* Force push Profiles and settings when using button

* Add "non-pump insulin" as treatment type (Artificial-Pancreas#267)

Co-authored-by: Jonas Björkert <bjorkert@me.com>

* Decrease opacity for temp basals in darkmode (Artificial-Pancreas#268)

* Add non-pump insulin dialog
* New entry dialog to add non-pump insulin in history view
* Removes `Add bolus without actually bolusing` functionality from the bolus entry dialog
* New dialog adds ability to back-date insulin entries
* Backdating is limited to past dates up to current date

* Danish Crowdin updates (Artificial-Pancreas#270)

* Upload when exiting settings, not just when using "Close button"

Fix for issue Artificial-Pancreas#260

* Ony upload profiles when changed, fix.

(cherry picked from commit dbb832b)

* Fix run script for branch name and commit ID to work with Xcode 15 (Artificial-Pancreas#274)

* BuildBranch fix for Xcode 15

- remove BuildBranch from Info.plist
- new Run script: get branch name and commit ID, replaces previous run script
- output to branch.txt
- use seven characters for the short commit reference, in line with GitHub
- run script early in build phases
- add branch.txt to FreeAPS project under FreeAPS/Resources
- add branch.txt to .gitignore
- read branch information from branch.txt also for upload of statistics in APSManager.swift

* Display build number like TestFlight (build number in brackets)

Previous style: iAPS v2.2.5 - 12
Changed to: iAPS 2.2.5 (12)

* Display Remote commands (Artificial-Pancreas#279)

Display remote commands from Nightscout in MainChart. 
Bolus, Temp basal, Open loop, Closed loop, Pump suspend, Pump resume.

* Layout fix for remotes.

* Layout of glucose data table

Make first row cleaner

* Add changes after PR revision
* Change button style and add a header row to list
* Add conditional filtering for future entries
* Add filter button that changes text

* Make button size for header row consistent with PR Artificial-Pancreas#272

* Streamline navigation views (Artificial-Pancreas#269)

* Streamline home view navigation views:
* Add title to carb entry view, as it was missing
* Streamlines all buttons (centered alignment, same size) for all coming-from-home-view dialogs/views

* Some changes after PR discussion
* Change navigation title style from `.automatic` to `.inline` for all views accessible from home screen
* Save screen space by moving (i) icon in bolus entry next to `Insulin recommended`
* Change color styling for (i) icon in bolus entry

* Revert info icon in bolus entry view back to speech bubble style"

* Use sheet instead of pop-up for manual glucose  (Artificial-Pancreas#272)

* Add sheet (new View) for adding manual glucose 
* Use glucose meter limits for manual glucose (0.8 - 40 mmol/l)

* Prevent Nightscout collisions from occurring when a transmitter ID is recycled (Artificial-Pancreas#285)

* Update DexcomSourceG5.swift

Generate unique _id value to prevent Mongo collisions in Nightscout

* Update DexcomSourceG6.swift

Generate unique _id value to prevent Mongo collisions in Nightscout

* Symbols mixed up.

* Style changes for treatments header row buttons by Jon

* Typo which prevented change of imported DIA setting

* Remove openaps setting insulin curve, becuse this now is a duplicate setting found also in pumpManagerUI settings

* Added other SF Symbols, changed text to "Add".

* Fix future entries condition
* Invert default to false (Jon initially said this to be default)
* Add comment to describe default
* Fix condition for treatment list data population

* Revert back to initial calendar SF Symbols

* Refactor Healthkit manager for Insulin

Refactor the code to sync with HK to be less battery drain. Limit to 100 last data.

* fix Blood glucose ID with Nightscout

Fix Artificial-Pancreas#280 with checking the compliance of ID as uuid. Not perfect (lost data in NS) but avoid the 500 error.
Fix for G7 sensor.

* Fixes for deletion and localization
* Removed unnecessary NSLocalizedString wrappers
* Remove obsolete `.alert()` that was blocking FPU and carb deletion alert

* Always display warning when over maxBolus

* update version

* UI. Clean up and chnge order of items

* revert background

* Implement alternative Bolus calculator (Artificial-Pancreas#286)

*New alternative bolus calc and toggle function in bolus calculator settings to switch between bolus calculators

* add options for fatty meals in bolus calc config settings and apply a custom override factor

* fix problem with DecimalTextFields which throw error UIViewAlertForUnsatisfiableConstraints

* Fix settings for new alternative bolus calc

* Use 1 maximumFractionDigit when mmol/l

* Refactor Bolus Calc. More to come.

* Update bolus recommedation (run a loop) every time opened, to update carbs, COB etc.
* Get carbRatio from Suggestion, like the other variables. Skip the loop, which sometimes didnt retrieve the CR (donät know why yet).

* Change labels (Artificial-Pancreas#289)

* All occurances of "Non-Pump" or "nonPump" in texts and code changed to "External"
* Removed label "Automatic" for SMBs in history

* Use fresh suggestion for both bolus calculators. Fresh as in updated every relevant oref variable, like COB, IOB etc.

* Bug fix for saved profiles regarding SMB and UAM basal minutes

* Small fixes for new bolus calc (Artificial-Pancreas#290)

* update enact bolus button description when amount exceeds maxBolus and fix insulin unit description

* reimplement continue without bolus button, delete unnecessary code in BolusStateModel

* refactor code and let add insulin button be disabled if maxBolus is exceeded

* remove unused variable

* Don't run the algo twice in a row

Reduce the delay

* Edit Meal entries from Boluse View (go back and forth).
Not working with the waiter's notepad yet, but can be fixed later, as it's not that important in this reagard.

(cherry picked from commit 3f5c93370ac27c5065bad5e14c64e2f2b5ee0318)

* Refactor.
Use CoreData.
Clean up (needs nore)

* Only use the CoreData data when needed

* Change labels (Artificial-Pancreas#289)

* All occurances of "Non-Pump" or "nonPump" in texts and code changed to "External"
* Removed label "Automatic" for SMBs in history

* Bug fix for saved profiles regarding SMB and UAM basal minutes

* fix typo in addGlucoseView in DataTableRootView which leads to save button always beeing disabled (Artificial-Pancreas#295)

* Fix deletion of fpus in NS. Still exessive, though.

* Fix update of calc

* Fix update and add config of UI

* Config overlay colour

* Alternate Bolus Calculator and Edit of Meals

* Implement new Bolus Calculator, by @polscm32, in Swift.

* Refactor the new calculator above and the UI/UX of the new Bolus View

* Add  Feature: Edit the Meals from the Bolus View . Go from the  Carbs View <--> Bolus View .

* Make button more descriptive

* Make button more descriptive

* Update Label

* Update Label

* A hack t0 make it appear as not saved until you enact or tap "Save"

* A hack to make it appear as not saved until you enact or tap "Save"

* Round to nearest increment

* Fix for deletion of previous entered carbs when entering addcarbs view through add meal button in bolus view (Artificial-Pancreas#297)

* Fix for deletion of previous entered carbs when entering addcarbs view through add meal button in bolus view (Artificial-Pancreas#297)

(cherry picked from commit b0a7bf4)

* Simpler UI. New bolus calc.

* Simpler UI. New bolus calc.

* Add Edit Meals also for the default Bolus View

* Add Edit Meals also for the default Bolus View

* Add Edit Meals also for the default Bolus View

* Structure the pop-up

* Structure the pop-up

* Streamline the default calc

* Streamline the default calc

* Update version

* New Localized Strings for the Bolus Views

* New localized String

* Only display "Continue without bolus" when insulin amount <= 0

* Act according to the "Skip bolus after carbs" setting

* Don't use glucoseStorage

* Fix Nightscout uploads being held back for FSL users (Artificial-Pancreas#300)

* Fix for bug after commit f039dc3. Carbs not uploaded to Apple Health … …due to wrong id in func (Artificial-Pancreas#301)

* Fix for deletion of previous entered carbs when entering addcarbs view through add meal button in bolus view

* Fix for bug after commit f039dc3. Carbs not uploaded to Apple Health due to wrong id in func

* Crowdin translations

* Reduce clutter.
Make more roome in Carbs View (needs more work). Button removed.
Move some of settings to UI/UX Section.

* Revert label (since already transleted)

* Structure settings a bit

* Mover more settings...

* Move dynamic ISF settings out from "OpenAPS" to "Extra Features" section

* Crowdin updates (Artificial-Pancreas#302)

Swedish and Dutch

* Crowdin updates (Artificial-Pancreas#302) (Artificial-Pancreas#303)

Swedish and Dutch

* Title

* Display "Comtine without boluse" as intended

* Add Back button

* Missing

* Crowdin updates (Artificial-Pancreas#304)

German and Italian

* Nother back button commit

* Make sure to later always fetch latest entry

* New meal view (Artificial-Pancreas#308)

Working draft.

* New wording

* Chart for predictions

* New Meal view and bolus views (Artificial-Pancreas#310)

* Chart for predictions Bolus view
* A bit cleaner Carbs View with better presets summary
* Back button and view meal entries in Bolus views

* Add Predictions to both bolus views.
Prevent force unwrapping of nil values.

* Save the standing or lying Chart setting.

* Save the standing or lying Chart setting.

* Add Eventual Glucose

* Use same buttons in both bolus views

* Display Eventual Gluose better
Wait for new suggestion

* Revert axis change

* Config

* New strings

* Update version

* Typo

* Typo

* Crowdin updates (Artificial-Pancreas#307)

* Localizations

* Update Bolus View and Meal View

Meal View
* Make presets UX/UI a bit cleaner (still far from perfect now)
* Make a summary for all presets and other entries used
* Make the important buttons blue and white (similar to Loop). 
* Prevent inadvertently changing the date of entry. Now you need to tap twice to change. Also allow for + - of 10 minute increments (also similar to Loop) with small button. 

Bolus View
* Display all of the glucose predictions in bolus view
* Display the future Eventual Glucose (end time depends on your DIA)
* Whilst waiting for the recommendation (including predictions) allow a manual bolus entry.
* Make the "Enact bolus" button blue, like in Loop.
* Allow to add end edit a meal also when you have Skip Bolus setting on. Bolus->Carbs->Bolus sequence is now allowed.

* Crowdin updates (Artificial-Pancreas#311)

* Fix types

* Crowdin Italian translations (Artificial-Pancreas#313)

* Change slider numbering position and add spacing Artificial-Pancreas#291 (Artificial-Pancreas#316)

* Update build_iAPS.yml (Artificial-Pancreas#318)

Trying latest Xcode version

* New translations localizable.string (Swedish) (Artificial-Pancreas#315)

* New strings

* Change temp target slider number position consistent with Artificial-Pancreas#291 (Artificial-Pancreas#321)

* Bolus from watch (Artificial-Pancreas#326)

Use same calculator on Watch as on iPhone app.

* New string

* Begin work for profile presets for watch app:
* Add new option under Settings > Devices > Watch to select between Temp Targets and Profiles
* Add new view PresetProfile for watch
* Add new conditional logic for the watch home view middle button, depending on selected setting
* Add some preliminary logic; untested and work in progress!

* Change default watch setting to preset; add preview

* Refactored presets view; added logic to en-/disable

---------

Co-authored-by: Jon B Mårtensson <53905247+Jon-b-m@users.noreply.github.com>
Co-authored-by: Jon Mårtensson <jon.m@live.se>
Co-authored-by: Liroy van Hoewijk <4643445+LiroyvH@users.noreply.github.com>
Co-authored-by: Andreas Stokholm <andreas@stokholm.me>
Co-authored-by: Pierre L <pn.lagarde@gmail.com>
Co-authored-by: Eugene Bashmakov <eugene.bashmakov@gmail.com>
Co-authored-by: Deniz Cengiz <48965855+dnzxy@users.noreply.github.com>
Co-authored-by: Jonas Björkert <bjorkert@me.com>
Co-authored-by: dnzxy <d.c.cengiz@googlemail.com>
Co-authored-by: bjornoleh <63544115+bjornoleh@users.noreply.github.com>
Co-authored-by: polscm32 <107251660+polscm32@users.noreply.github.com>
Co-authored-by: dsnallfot <72826201+dsnallfot@users.noreply.github.com>
Co-authored-by: sethgagnon <597958+sethgagnon@users.noreply.github.com>
Jon-b-m pushed a commit that referenced this issue Nov 22, 2023
Fix #280 with checking the compliance of ID as uuid. Not perfect (lost data in NS) but avoid the 500 error.
Fix for G7 sensor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants