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

Update to last loop frameworks allowing to use omni dash pump #207

Open
wants to merge 53 commits into
base: master
Choose a base branch
from

Conversation

avouspierre
Copy link

Integration of the September 2022 loop framework and including the dash framework (BLE) provided by Loop team. Lot of changes in this implementation in FAX but 6 months of testing with few people - see discord channel -

Documentation of the update are here : https://github.com/avouspierre/freeaps

avouspierre and others added 30 commits August 26, 2022 14:40
…ion and store the alert in a alertStore array
Correction to setupUnits calc to correctly reflect IOB after initialising and priming a new pod

Co-Authored-By: Joe Moran <[email protected]>
allow correct IOB to be calculated after initialising a new pod
Add ability to create a permanent override file for signing the app as is done in Loop (dev branch) and FreeAPS (freeaps_dev branch).
Look up 2 levels for an OverrideConfig.xcconfig file and use that if it exists. 

Note, because the name differs from that used for Loop, there is no conflict if both files are in the same folder.

This will simplify life for anyone using a script to build and for any developer who might have several different test branches going.
For example: I have a copy in my ~/Downloads/ManualClones folder and do all clones one level down from that, e.g., ~/Downloads/ManualClones/FAX-descriptor-date/freeapsx
(cherry picked from commit b0f41a7)
avouspierre and others added 23 commits September 10, 2022 14:16
…t basal temp.

compile with the Xcode Version 14
It affected also the basal rate schedule, not only the totals.
- xDrip4iOS stores the CGM address in shared user defaults
- FreeAPS X reads this address and connects to the CGM
   - it does not process any data
   - it is only used to guarantee a regular wake up, which is each time the CGM connects, disconnects or sends data
   - when this wake up happens, FreeAPS X triggers by itself a call to fetchLastBGs()
- There is no need to initiate a scanning, it will automatically detect the CGM address in the shared defaults and connect to it
- To remove the connection, one must either
   - disconnect the CGM in xDrip4iOS (this will force the value in shared user defaults to nil)
   - remove xDrip4iOS in Free APS X

- I also had to make a change in ConcreteGlucoseDisplayable, enum GlucoseTrend, to add a description var (seems rather messy usage of glucose trend definitions in the code)

Still to do
- maybe add a field in the xDrip4iOS UI to show the name of the CGM transmitter to which FeeAPS X connects

(cherry picked from commit 2686a97)
The CGM Bluetooth address is a unique. xDrip4iOS writes the address to shared user defaults as soon as it connects to a CGM.
FAX reads this address and uses the device as heartbeat.

This commit makes the address visible in the UI and can be compared to the address visible in xDrip4iOS

(cherry picked from commit 82de85c)
This is a workaround to make the BT heartbeat work on time.

Ideally, a function should be defined here : https://github.com/JohanDegraeve/freeaps-avouspierre/blob/82de85cf6e7138db09924308050cb558ee514feb/FreeAPS/Sources/APS/CGM/HeartBeatManager.swift#L59
This function is called whenever the BT device connects/disconnects or sends data.
With Dex, this would mean there would be several calls to this function, because Dex typically connects, sends several data packets, and finally disconnects, and even after that, continues to connect/disconnect for a few times. (About 10 seconds, then Dex goes to sleep for 5 minutes)
By the last disconnect, xDrip4iOS would already have had the chance to write a new reading in the shared user defaults

But, as the code is rather complex, I could not find which function to add in that heartbeat closure. That's why it's just empty '{}'

So the workaround is to make use of a timer that Ivan implemented. See here https://github.com/JohanDegraeve/freeaps-avouspierre/blob/82de85cf6e7138db09924308050cb558ee514feb/FreeAPS/Sources/APS/FetchGlucoseManager.swift#L19

This timer triggers a new BG reading fetch, originally every minute, with this change here, every second.
A timer is also not ideally. Actually Apple says timers should be canceled when the app goes to the background. Ideally, as described above, the heartbeat function should trigger the BG reading fetch.
But, as Ivan used a timer here, here's what happens
- the timer is created the moment the app launches
- timer expires every interval (originally 1 minute, now 1 second)
- every interval a BG Reading fetch is triggered
When the user brings the app to the background :
- iOS will suspend the app within a few seconds, means the app goes in sleep mode
- the timer will not expire anymore
- As soon as there's BT activity, iOS wakes up the app
- now the timer will continue to do it's work again, which is expire and run the BG reading fetch.
But, in the setup where xDrip4iOS is used, it's actually xDrip4iOS that decodes the data received from Dexcom.
When Dexcom connects, both xDrip4iOS and FAX are woken up by iOS.
xDrip4iOS needs a few seconds to receive the new reading
The timer at FAX expires immediately, but the new reading is not immediately available.
If it's to expire only a minute later, then it will not have the latest reading.
By setting it to 1 second interval, the timer will have the chance to expire a few times (about 5 - 10 times), before iOS brings back the app to sleep.
But during those 5-10 seconds (actually 2 is probably enough), xDrip4iOS has written a new reading to shared defaults, and FAX has the chance to get the latest reading.

As said, this is a workaround.

(cherry picked from commit 8ad09e3)
(cherry picked from commit 47f9503)
(cherry picked from commit 8b133c1)
…gits

Limit both total scheduled and AT basal to 1 fraction digit
@mountrcg
Copy link
Contributor

mountrcg commented Jan 7, 2023

Whooohooo!

@becksen
Copy link

becksen commented Jan 7, 2023

I can confirm no issues with DASH pod in @avouspierre implementation. Please merge it.
Best regards

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.

8 participants