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

raise BG target for noisy / raw CGM data #833

Merged
merged 23 commits into from
Dec 25, 2017
Merged

Conversation

scottleibrand
Copy link
Contributor

When looping off of noisy / raw CGM data (during sensor swaps, on noisy sensors, etc.) it would be safest to adjust the BG target upward to provide an extra safety buffer for erroneous or miscalibrated CGM data. This PR defaults the noisyCGMTargetMultiplier to 1.3, and adjusts the default maxraw value accordingly, from 150 to 200. This will allow looping off raw/noisy CGM data values up to 200 mg/dL, but with an elevated target of 130% of normal.

This incorporates #735 to do the same for xDrip noise values >= 2 as for Dexcom raw BG values <= 200. Dexcom raw values > 200, and xDrip noise values >= 3, will prevent looping entirely.

There is one remaining TODO, to support maxRaw in preferences.json. The g4-upload config current does everything in a separate myopenaps-cgm-loop directory, so can't read myopenaps/preferences.json. We'll probably want to refactor g4-upload to be more like g4-upload, which will simplify the config a lot and also make it much easier to read preferences.json.

Thoughts?

@alimhassam
Copy link
Contributor

alimhassam commented Nov 29, 2017

Reviewed with the latest changes, the noise approach seems sound to me (except the small issue might have been due to merging which needs to be corrected). I'll try to merge this to my local branch to test.

For the raw glucose logic, I don't think i fully understand it. Not fully related to this pr, but it seems like it's trying to use calibration records from the old sensor to calculate bg for the new sensor on sensor changes? Did I get this right? Is that a safe thing to do?

@scottleibrand
Copy link
Contributor Author

@alimhassam I don't see your review noting the small issue. Did you hit Submit on it?

We do not explicitly recommend looping on an uncalibrated sensor (or a receiver calibrated from a previous sensor), but have personally seen better outcomes doing that (with appropriate limitations on maxRaw and with appropriate BG or target adjustments, as are in this PR) rather than stopping looping entirely for 2h. More commonly, those using Dexcom receivers will restart the receiver's sensor session after 7 days without actually replacing the sensor, in which case the old calibration record is still perfectly good for the new session.

var noise = glucose_status.noise;
// 38 is an xDrip error state that usually indicates sensor failure
// all other BG values between 11 and 37 mg/dL reflect non-error-code BG values, so we should zero temp for those
if (bg <= 10 || bg == 38 || noise >= 3) { //Dexcom is in ??? mode or calibrating, or xDrip reports high noise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check needs to be mirrored on line 77 as well, i think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, didn't realise i needed to press submit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch, thanks.

@alimhassam
Copy link
Contributor

alimhassam commented Nov 29, 2017

Right, makes sense for the old sensor case, but i'm a bit skeptical/surprised it's safe on a new sensor. Probably outside the scope of this pr.

@tim2000s
Copy link
Contributor

Let me try out the noise management approach that Adrian mentioned in the issue before merging this in.

Ideally I’d like to be able to choose whether it goes more conservative at 2 or 3 and the behaviour based on some longer term testing before merging.

@scottleibrand
Copy link
Contributor Author

Ok, I’ll wait a bit. We can always make further adjustments after it’s in dev, though. Once we’re confident this is better than the status quo we can go ahead and merge it for further testing in dev.

@philipgo
Copy link
Contributor

philipgo commented Dec 3, 2017

We have tested this PR with XDrip+ and it works as intended. I think this is a great safety improvement!

// adjust target BG range if needed to safely bring down high BG faster without causing lows
if ( bg > max_bg && profile.adv_target_adjustments && ! profile.temptargetSet ) {
// raise target for noisy / raw CGM data
if (glucose_status.noise >= 2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we say something in the reason field when this situation occurs?

@alimhassam
Copy link
Contributor

alimhassam commented Dec 4, 2017

Been running a couple of days with this change as well and it works well for me so far on xdrip+ and g5.

Generally very happy with the change, definitely an improvement.

@philipgo
Copy link
Contributor

philipgo commented Dec 6, 2017

We just had a sensor failure (XDrip+/G5) and everything worked as intended. I just saw in @jamorham 's comment NightscoutFoundation/xDrip#191 (comment) that noise can also be "0" which is an error state or means that noise cannot be computed. I think that we should thus also exclude BG values where noise=0. (I have zero readings in our database where this is the case, so this will not prevent looping on useful values)

@scottleibrand
Copy link
Contributor Author

Based on the feedback from @drnoname82 and @alimhassam I think we should go ahead and merge this and make any further tweaks in a new PR.

@philipgo
Copy link
Contributor

Thumbs up! The PR has also proven quite useful in avoiding useless changes in insulin delivery due to compression lows and subsequent sharp rises, usually accompanied by high noise.

@tim2000s
Copy link
Contributor

I’ve no issue with this pr stopping looping at noise level 3, but at noise level 2 I don’t see enough variation from 1 for it to cause an issue with looping.

I think the level of noise a user accepts should be a hidden preference. Especially when you consider how many people are extending the life of a sensor.

For me, I’d prefer to continue to loop at 2 and remove SMB at 3. I’m comfortable that the smoothing components of the original oref0 algorithm manage unexpected deviations effectively when using a TBR-only model.

@alimhassam
Copy link
Contributor

@tim2000s this changes is done in such a way that looping continues at noise level 2, but slightly more conservatively, was that your understanding?

(I've been using thing for more than 1 week, and it works well, for me)

@tim2000s
Copy link
Contributor

Yes, that is my understanding. My point is that I’ve been looping with xdripaps for the best part of a year. In that time the periods where Dex reported 3 (xDrip didn’t for a long time) were problematic when using SMB but the look back in the oref0 TBR based code actually allowed it to loop effectively with highly noisy readings.

The noise level 2 in my observations seems really rare and to have a very low deviation from 1. I don’t think we should just PR something into Dev because it “feels” safer without properly quantifying the improvement. From a purely observational point of view, the 3 level of noise really needs to shut down SMB and I’d agree that it’s marginal that some would continue to loop and others wouldn’t using TBRs.

At noise level 2 I don’t see enough deviation nor a long enough duration of 2s to justify making the targets more conservative. I’m happy to be quantifiably proved wrong, but that’s my point of view.

@alimhassam
Copy link
Contributor

Ok, i won't argue your suggested behavior for noise level 3, there might be way to still loop safely, and improvements around this might be interesting.

For noise level 2, if they rarely occur in your case, than the behavior here won't affect you much (or rarely).

I personally get noise=2 almost daily. I did finger pricks comparison a couple of times, and compared with the rest of the curve around the time, at it generally reflects a jump in the unfiltered reading, which granted, gets somwhat smoothed out by the xdrip+ algorithm, but does represents uncertainty.

I think being more conservative around such uncertainty a good thing. Before merging this branch I did get one occurrence where smb activated for a mild bg jump with noise=2. There were Cob on, which resulted in an extra bolus and a followup low, and that's the reason i started looking at noise issues more closely.

Of course, if you have access to more data, and are able to get "proper quantifying" that would be much better.
There is already a preference setting to change how much you want to adjust the target for noisy readings. I think the default adjustment is relatively mild at 1.3, but if you If you want update the pr to improve and make this setting more granular or do something different, or add other ones maybe for noise=3 that might be good too, as long as this current behavior can still be achieved.

Personally (with my limited experience&data) the current implemented behavior seems to fix the issue i was having with noisy readings.

@philipgo
Copy link
Contributor

philipgo commented Dec 14, 2017

I just went through the past few days of CGM data. My original opinion was to only loop off CGM data with a noise level of 1. I agree with @tim2000s that at least our data does not justify that. We see ca. 5% data with noise=2. I failled to find any obviously wrong readings within the past week. However, I find that raising the target for CGM readings with a certain level absolutely justified.

How about merging this PR as is and gathering more data? It definitely is a safety improvement and I find looping with a raised target for ca. 5% of the time completely acceptable. If others see much more noise=2 readings, that might be a different situation. I think most users are not even aware that XDrip now provides noise levels and we will only get more opinions if this is merged to dev.

@tim2000s
Copy link
Contributor

It’s tricky because the inherent functionality built into oref0 is halfway to a Kaplan filter, limiting the variation that the future predictions will have by looking at past deviations and comparing them to what the expected behaviour is, rather than relying on the individual readings.

My preferred (but much more complex solution) would be to apply a Kaplan filter based on the noise data rather than simply shut off looping or increase the target. That does require work though.

@alimhassam
Copy link
Contributor

That's an interesting idea @tim2000s you basically want to update the oref0 algorithm to work of the raw filtered and unfiltered data and do its own noise working. This could get better error estimate rather that just a single noise number, as that would be part of the kalman filter output.

xdrip+ already implements such noise workings but only outputs a single number rather that full error variance.

But I suspect that once the error variance estimate is produced, thr resulting dosing decision will end up being very similar to what was done in this pr. Ie raise BG target when error estimate increase.
The advantage of your approach is that since the error might be more quantifiable and we can change the target more precisely than only based on the less precise noise number.

But I think the main idea would be the same. Correct me if I missed or misunderstood something.

@philipgo
Copy link
Contributor

We have been testing this for weeks without any issues. Yesterday we had a situation where a perfectly fine sensor drifted too low and then jumped significantly too high (CGM 270, BG 190) with noise reported as "light" for about twenty minutes, afterwards noise was reported as high/extreme. So I think treating CGM readings with light noise conservatively is more than justified.

The reasoning in Nightscout is clear for noise values >= 3 but I did never see any reasoning in the OpenAPS pill when target was raised due to noise=2.

I only just saw that there is a preference NoisyCGMTargetMultiplier allowing anyone wishing to do so trust those CGM values more. I think this PR is good to merge since by providing this variable it mean s hardly any limitation for those wishing to loop off lightly noisy values.

@scottleibrand
Copy link
Contributor Author

Hearing no objections that aren’t addressed by the ability to set preferences, I’m merging this to dev.

@scottleibrand scottleibrand merged commit 6f42c94 into dev Dec 25, 2017
@scottleibrand scottleibrand deleted the raw_safety_multiplier branch January 8, 2018 00:32
ThomasEmge added a commit to ThomasEmge/oref0 that referenced this pull request Dec 5, 2018
* fix remaining references to half_basal_target (#712)

* fix remaining reference to half_basal_target

* fix remaining reference to half_basal_target

* raise SMB-disable threshold to > 20% of bg to catch fast carb rises (#717)

* BlueZ update - min  version 5.47 due (BlueBorne vulnerability fix) (#724)

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-1000250
http://www.bluez.org/release-of-bluez-5-47/

* fix logic fail for ! enableUAM case to set minGuardBG from COB (#721)

* Upload entries from G5 to nightscout (#718)

* Update packages.json

Add the new script

* oref0-upload-entries.json

This script uploads new CGM entries to Nightscout. If the network connection is lost for a period of time the entries from the last time the upload was successful (stored in ``entries-last-date.json``) buffer in ``entries-upload.json`` until the next successful upload, at which point the file is deleted. This allows the device to be offline for any number of days and you get all the entries, not just the last 288, once it comes back online.

* Rename oref0-upload-entries.json to oref0-upload-entries.sh

* Update oref0-setup.sh to support "g5-upload" CGM type

* Add the Bash indicator

* Eliminate basal vs. bolus distinctions (#685)

* remove all explicit references to basaliob

* add enableSMB_always preference, but don't add to displayedDefaults yet

* comment out all bolus snooze code

* comment out bolus snooze / IOB code

* comment out bolus snooze code

* comment out bolus snooze code

* comment out bolus snooze code

* remove bolus snooze code

* comment out bolus snooze code

* comment out bolus snooze test

* uncomment eventualBG < max_bg code and remove snoozeBG

* comment out bolus snooze tests

* rate <=0

* no more need to track hightempinsulin

* no more need to track netbasalinsulin

* no more need to track microBolus(IOB|Insulin)

* remove one more bolus snooze reference

* re-add basaliob and netbasalinsulin etc.

* oref0-ns-loop (#713)

* use IPv4 only to wget

* add package-lock.json to .gitignore

* match on spidev0.0 already in use too for Pi with Explorer HAT

* first untested attempt at moving ns-loop aliases into oref0-ns-loop.sh

* add oref0-ns-loop

* syntax

* fix get_ns_bg

* change ns_temptargets back for now

* improve logging

* improve logging

* return not exit

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* install new oref0-ns-loop

* revert to settings/temptargets.json for now

* improve logging

* don't wait for 40s twice on random failures

* consistent messaging regardless of mmeowlink version

* syntax

* fix comment

* killall bluetoothd again immediately before installing it (#726)

*  apply 20g/h carbAbsorptionRate to COB not total carbs (#715)

* apply carbAbsorptionRate to COB not total carbs

* round allDeviations array for readability

* change initial carbAbsorptionRate assumption to 20g/h

* fix broken safety checks with a single pump-loop type (#725)

* consolidate down to a single pump-loop type

* touch /tmp/pump_loop_completed even w/o SMB

*  in two more places

* replace chained && with || fail

* syntax

* syntax

* timeout ns-get curls after 30s (#728)

* 0.6.0-dev2

* Fix pump-loop (#729)

* install SMB aliases regardless for pump-loop to work

* remove no-longer-applicable comments

* chmod +x bin/*.sh

* predBGs with zero temps (#714)

* remove all explicit references to basaliob

* add enableSMB_always preference, but don't add to displayedDefaults yet

* comment out all bolus snooze code

* comment out bolus snooze / IOB code

* comment out bolus snooze code

* comment out bolus snooze code

* comment out bolus snooze code

* remove bolus snooze code

* comment out bolus snooze code

* comment out bolus snooze test

* uncomment eventualBG < max_bg code and remove snoozeBG

* comment out bolus snooze tests

* rate <=0

* no more need to track hightempinsulin

* no more need to track netbasalinsulin

* no more need to track microBolus(IOB|Insulin)

* remove one more bolus snooze reference

* re-add basaliob and netbasalinsulin etc.

* add IOBWithZeroTemps

* calculate iobWithZeroTemp

* include the entire iobWithZeroTemp array

* calculate ZTpredBGs

* show all ZTpredBGs for now

* use predZTBGI for ZTpredBGs

* stop displaying ZTpredBGs once they're rising and above target

* calculate and log minZTUAMPredBG

* use minZTUAMPredBG to adjust dosing

* debugging output

* only show 30m of ZTpredBGs if rising above target

* disable aCOB for now

* use >= to make it more clear when ZTpredBGs have flattened out

* fix logic

Conflicts:
	lib/determine-basal/determine-basal.js

* if avgPredBG is below minZTGuardBG, bring it up to that level

* start the zero temp 1m in the future to avoid clock skew

* if minZTGuardBG is between threshold and target, blend in the averaging

* move minZTUAMPredBG outside of if (meal_data.carbs)

* round minZTUAMPredBG for readability

* round predCIs for readability

* round remainingCIs for readability

* align predCIs and remainingCIs

* fix comment

* copy old_preferences.json for reference

* disable adv_target_adjustments and enableUAM by default

* use old ns-loop for MDT CGM for now (#730)

* Use autosens basal adjustments in IOB calculations (#705)

* set exercise mode basal and ISF based on temptarget

* adjust slightly less, and only if temptarget > 110

* for temptargets > 110, adjust sensitivityRatio and IOB

* don't set neutral temp if carbsReq

* make sure autosens doesn't use temptarget-adjusted insulin calculations

* define var sensitivityRatio

* define basal before bg < 39 check

* allow exercise mode to be disabled in preferences.json

* flag autosens IOB calculations to avoid feedback loops

* make temptarget that generates 50% basal configurable

* pass optional autosens data for IOB recalculation

* pass optional autosens data for IOB recalculation

* use new formula in calculating IOB too

* actually update basal before calculating IOB

* use autosens_data if defined

* make it work

* turns out we don't need this

* pass autosens.json to calculate-iob

* disable autosens_adjust_targets by default now

* don't adjust carb_ratio with autosens

* adjust remainingCATime (instead of CR) for autosens

* stop excluding positive deviations as soon as mealCOB=0 if meal has been absorbing for >5h

* add one neutral deviation per hour to help decay over long exclusion periods

* use 0.5 cutoff for rounding

* no more need for a gap now that we're paddng with hourly 0 deviations

* clearer reporting of % negative vs. positive deviations

* only add one neutral deviation every 2 hours

* add negative deviations for high temp targets

* add EdisonVoltage upload back in to oref0-ns-loop (#731)

* add EdisonVoltage upload back in

* no more need for edisonbattery aliases now that they're in oref0-ns-loop.sh

* jq pretty colors

* jq pretty colors

* clarity

* check preferences.json is valid json (#738)

* check preferences.json is valid json

* please go correct your typo

* Only SMB every 3m; retry up to 2m (#744)

* only SMB every 3m now that we retry

* retry SMB if for up to 2m if waiting

* adding cron start/stop aliases (#746)

* adding cron stop/start aliases

* typo fix

* round insulinReq down to nearest 0.1U to safely allow eSMB on small basals (#732)

* make sure all apt-get packages are up to date (#733)

* Limit carb impact predictions to 30g/h (#740)

* limit Carb Impact to 12 mg/dL per 5m

* limit Carb Impact to 12 mg/dL per 5m before calculating CATime

* limit carb impact based on maxCarbAbsorptionRate = 30 g/h

* allow use of 39 (LOW) to calculate currentDeviation

* disable SMB if either avgDelta is >20% too (#742)

* pad up to 90m of zero deviations after site change (#743)

* upgrade to mmeowlink v0.11.1 for clearer pump comms messaging (#534)

* only use monitor/edison-battery.json if it exists (#750)

* match on spidev5.1 to indicate explorer (for runagain); fix if syntax (#751)

* optionally allow SMBs with activity mode (#734)

* if disableSMB_with_temptarget: false, allow (smaller) SMBs with high targets

* limit Carb Impact to 12 mg/dL per 5m

* limit Carb Impact to 12 mg/dL per 5m before calculating CATime

* limit carb impact based on maxCarbAbsorptionRate = 30 g/h

* allow use of 39 (LOW) to calculate currentDeviation

* go back to profile.sens to allow activity mode sensitivityRatio to adjust CR

* always print old and new ISF

* preflight after rssi_wait to make other rigs keep rssi_waiting

* print CR

* print CR

* clarify disableSMB_with_temptarget: true to be allowSMB_with_temptarget: false

* that should be allowSMB_with_high_temptarget not allowSMB_with_temptarget

* more user-friendly output when there aren't any temptargets

* remove "Excess"

* check validity of iob.json and profile.json and refresh if invalid (#745)

* check validity of iob.json and profile.json and refresh if invalid

* bash doesn't like empty if clauses

* specify which file was invalid

* only check profile.json not iob.json in refresh_old_profile

* don't proceed to a suggested.json if report invoke fails

* call determine-basal directly, not via openaps

* convert openaps get-settings to get_settings with error checking

* just check validity, not contents

* cleaner log output

* convert settings/pumpprofile.json to direct, and get rid of No temptargets warning

* Fix edisonbattery for MDT and xDrip. (#752)

* Revert "add EdisonVoltage upload back in to oref0-ns-loop (#731)"

This reverts commit a865517fcc575e118015c056ea565a3b4b8011f4.

Conflicts:
	bin/oref0-setup.sh

* revert

* use old ns-loop for xdrip too

* 0.6.0-dev3

* remove duplicate from merge conflict

* Calculate UAM and eventualBG when insufficient data for COB (#747)

* Optimize oref0-ns-loop.sh (#739)

* don't get_ns_bg if fresh; only run every 5m if highload

* fix glucose fresh check

* json is slow: just check file age

* use oref0_glucose_since directly; only get 24h of glucose every hour

* syntax

* use nightscout carb_history directly

* set mtime of ns-glucose.json based on its last reading

* update glucose-24h.json if not enough glucose to calculate COB

* undefined check

* on insufficient glucose data, only set COB to 0; still do UAM

* A52 risk reduction (#749)

* add A52_risk_enable setting in preferences.json

* calculate and return nsCarbs vs. bwCarbs for A52 safety checks

* don't need these

* SMB not enabled for Bolus Wizard

* don't enable SMB without A52_risk_enable if bolus wizard in use

* print SMB disabled when ! microBolusAllowed

* more/better SMB enabled logging

* this is actually only 6h for now

* comment out undefined/unused variable

* press ESC three times on the pump to exit Bolus Wizard before SMBing, to help prevent A52 errors

* clean up press_keys output

* send all three esc in a row, and don't bolus unless successful

*  press ESC three times on the pump to exit Bolus Wizard before SMBing (#753)

* press ESC three times on the pump to exit Bolus Wizard before SMBing, to help prevent A52 errors

* clean up press_keys output

* send all three esc in a row, and don't bolus unless successful

* log what we're doing with ESC ESC ESC

* don't treat suspended pump as a complete failure (#755)

* 0.6.0-dev4

* change default curve to rapid-acting (#769)

* Remove unnecessary verbose logging of the oref0-subg-ww-radio-paramet… (#763)

* Remove unnecessary verbose logging of the oref0-subg-ww-radio-parameters.

This logs every line being executed, which is probably overkill and fills the pump loop logs.

* Commenting out set -x

per @pietergit's recommendation

* Offline local-only wifi hotspot (#716)

* refactor oref0-online to use functions

* start_hotspot if no connectivity; stop_hotspot if online via BT

* refactor one more check_ip

* pass MACs to function

* pass MACs to function

* pass MACs to function

* stop/start backwards

* check if hostapd is running before stop/start

* stop_hotspot if running any time we have a public IP

* logic

* grep -q  instead of checking pid

* syntax

* make variables global

* ifup before hostapd; systemctl daemon-reload

* ifdown/ifup wlan0 in stop_hotspot

* stop_hotspot when we get BT

* try ifdown later

* stop udhcpd before starting dnsmasq

* echo

* no more need for sleep

* install prerequisites and configs for local-only hotspot

* only do local-only hotspot if BT configured

* offline webapp

* check if wlan0 is still in AP mode

* pass MACs to start_hotspot

* make sure hostapd and dnsmasq services are running if hotspot is up

* only stop hotspot if we have internet

* get ns-temptargets directly, then merge with any local-temptargets

* print temptarget start time

* untested set-local-temptarget.js

* use current time if unspecified

* oref0-set-local-temptarget

* oref0-append-local-temptarget

* oref0-append-local-temptarget

* regenerate profile after refreshing temptargets

* regenerate profile after merging temptargets

* allow oref0-append-local-temptarget.sh to run oref0-set-local-temptarget

* parse inputs as integers

* remove spurious output

* delete any local-temptarget files last modified more than 24h ago

* make offline_hotspot a preference, false by default

* per #716 it'd be better for xDrip to keep BT connected when offline

* if no wifi and no BT, try cycling wlan0

* make sure all apt-get packages are up to date

* Optimize oref0-ns-loop.sh (#739)

* don't get_ns_bg if fresh; only run every 5m if highload

* fix glucose fresh check

* json is slow: just check file age

* use oref0_glucose_since directly; only get 24h of glucose every hour

* syntax

* use nightscout carb_history directly

* set mtime of ns-glucose.json based on its last reading

* write profile.json.new and validate before mv'ing

* don't trust awk exit status

* cd to ~/myopenaps for oref0-online to read preferences.json

* Create linux-bootup.sh

Instructions for /etc/rc.local startup

* Update oref0-setup.sh

Stop automatic startup of hostapd & dnsmasq

* Update oref0-setup.sh

add linux-bootup.sh to /etc/rc.local

* Update linux-bootup.sh

check to see if .conf actually exists before overwriting with an empty file.

* Update oref0-setup.sh

Edit /etc/hostapd/hostapd.conf for Hostname and wpa

* Update package.json

add linux-bootup.sh

* Delete linux-bootup.sh

bad idea

* Update package.json

removed bad idea

* Update oref0-setup.sh

removed bad idea and writing to rc.local directly

* Update oref0-setup.sh

change hotspot name

* Update oref0-setup.sh

add wpa security for Hotspot with #OpenAPS

* Update oref0-setup.sh

add logic to rc.local

* Update hostapd.conf

add security to hotspot

* Update oref0-setup.sh

Changes for Hotspot setup

* Update oref0-setup.sh

change to setup for local-only hotspot

* Update oref0-setup.sh

changes for the different type of wpa-roam or wpa-conf

* reverse logic so failure = not enabled

* remove HostAPDIP if still configured after stop_hotspot

* Update oref0-online.sh

Changes to improve oref0-online

* Update oref0-setup.sh

changes to cron

* syntax

* if online via BT, cycle wlan0

* check for interfaces.ap; stop_hotspot if not enabled

* reorder to always stop_hotspot if not enabled

* don't release hotspot IP; reorder to stop_hotspot w/o BT MAC

* add /tmp/disable_hotspot support

* grammar capitalization etc.

* logic

* don't wait for 47 years if clock is mismatched

* mv offline folder to www so it doesn't conflict with branch name

* only release the wifi IP/route if it's from DHCP

* whitepace

* print Connected to Bluetooth with IP:

* consistency

* display wifi is not connected if no SSID

* whitepace

* consistency

* whitepace

* consistency

* whitepace

* print unassigned if no

* reorder and print local wifi/BT IPs separately

* syntax

* print name of phone we're connected to with Bluetooth

* only run check_ip once

* print start/finish times

* don't try to dhcp_renew when running hostapd

* print when PUBLIC_IP not found

* fix return code

* don't renew wlan0 IP/route if it's failing

* logging

* syntax

* don't wifi_dhcp_renew if bad_wifi

* f we can't connect via BT, might as well try previously bad wifi networks again

* remove extra -HotSpot from SSID

* disconnect bnep0 even w/o an IP

* temporarily disable hotspot for 1m every hour to allow it to try to connect via wifi again

* download carbhistory to carbhistory.json.new and mv it over if valid

* egrep quietly

* download ns-temptargets to .new and mv it over if valid

* escape $directory for crontab

* let's play spot that syntax error

* only retry SMB w/o waiting if it was <1 m wait

* change default curve to rapid-acting

* 0.6.0-dev5

* oref0-version (#759)

* oref0-version.js

Check and report current oref0 version as well as check for changes on remote.

* adding oref0-version

* Update oref0-version.js

* Add oref0-version check every hour.

* Language tweaks

* Revert "Add oref0-version check every hour."

This reverts commit 846b0f20857c89d320f7493a9dcd2f43d8dcb3b4.

* check-for-updates after each successful pump-loop

* replace backticks with quotes

* chmod +x

* port oref0-version.js to bash to avoid nodejs compatibility issues

* switch to oref0-version.sh to avoid nodejs compatibility issues

* rm oref0-version.js now that oref0-version.sh works

* don't display git fetch output

* revised text for master

* remove extra newlines to save space

* timeout git fetch after 30s if it hangs

* grammar

* tabs to spaces

* only check-for-updates once an hour, outside of pump-loop

* Removing "enable" requirement for SMB - use preferences only  (#748)

* remove extra SMB safety gates

* remove remaining  references

* kill bluetoothd AFTER download in case WAN access is through bluetooth (#771)

* Sensitivity and targets (#757)

* replace autosens_adjust_targets with more detailed preferences

* split autosens_adjust_targets to sensitivity_raises_target and resistance_lowers_target

* add low_temptarget_lowers_sensitivity support

* update comments to be correct

* make high-temptarget added deviations half as strong

* store/upload sensitivityRatio

* adjust CSF for temptarget sensitivityRatio, but not for autosens

* let 105-110 temp target trigger exercise mode

* oref0-autosens-loop (#767)

* refactor oref0-online to use functions

* start_hotspot if no connectivity; stop_hotspot if online via BT

* refactor one more check_ip

* pass MACs to function

* pass MACs to function

* pass MACs to function

* stop/start backwards

* check if hostapd is running before stop/start

* stop_hotspot if running any time we have a public IP

* logic

* grep -q  instead of checking pid

* syntax

* make variables global

* ifup before hostapd; systemctl daemon-reload

* ifdown/ifup wlan0 in stop_hotspot

* stop_hotspot when we get BT

* try ifdown later

* stop udhcpd before starting dnsmasq

* echo

* no more need for sleep

* install prerequisites and configs for local-only hotspot

* only do local-only hotspot if BT configured

* offline webapp

* check if wlan0 is still in AP mode

* pass MACs to start_hotspot

* make sure hostapd and dnsmasq services are running if hotspot is up

* only stop hotspot if we have internet

* get ns-temptargets directly, then merge with any local-temptargets

* print temptarget start time

* untested set-local-temptarget.js

* use current time if unspecified

* oref0-set-local-temptarget

* oref0-append-local-temptarget

* oref0-append-local-temptarget

* regenerate profile after refreshing temptargets

* regenerate profile after merging temptargets

* allow oref0-append-local-temptarget.sh to run oref0-set-local-temptarget

* parse inputs as integers

* remove spurious output

* delete any local-temptarget files last modified more than 24h ago

* make offline_hotspot a preference, false by default

* per #716 it'd be better for xDrip to keep BT connected when offline

* if no wifi and no BT, try cycling wlan0

* make sure all apt-get packages are up to date

* Optimize oref0-ns-loop.sh (#739)

* don't get_ns_bg if fresh; only run every 5m if highload

* fix glucose fresh check

* json is slow: just check file age

* use oref0_glucose_since directly; only get 24h of glucose every hour

* syntax

* use nightscout carb_history directly

* set mtime of ns-glucose.json based on its last reading

* write profile.json.new and validate before mv'ing

* don't trust awk exit status

* cd to ~/myopenaps for oref0-online to read preferences.json

* Create linux-bootup.sh

Instructions for /etc/rc.local startup

* Update oref0-setup.sh

Stop automatic startup of hostapd & dnsmasq

* Update oref0-setup.sh

add linux-bootup.sh to /etc/rc.local

* Update linux-bootup.sh

check to see if .conf actually exists before overwriting with an empty file.

* Update oref0-setup.sh

Edit /etc/hostapd/hostapd.conf for Hostname and wpa

* Update package.json

add linux-bootup.sh

* Delete linux-bootup.sh

bad idea

* Update package.json

removed bad idea

* Update oref0-setup.sh

removed bad idea and writing to rc.local directly

* Update oref0-setup.sh

change hotspot name

* Update oref0-setup.sh

add wpa security for Hotspot with #OpenAPS

* Update oref0-setup.sh

add logic to rc.local

* Update hostapd.conf

add security to hotspot

* Update oref0-setup.sh

Changes for Hotspot setup

* Update oref0-setup.sh

change to setup for local-only hotspot

* Update oref0-setup.sh

changes for the different type of wpa-roam or wpa-conf

* reverse logic so failure = not enabled

* remove HostAPDIP if still configured after stop_hotspot

* Update oref0-online.sh

Changes to improve oref0-online

* Update oref0-setup.sh

changes to cron

* syntax

* if online via BT, cycle wlan0

* check for interfaces.ap; stop_hotspot if not enabled

* reorder to always stop_hotspot if not enabled

* don't release hotspot IP; reorder to stop_hotspot w/o BT MAC

* add /tmp/disable_hotspot support

* grammar capitalization etc.

* logic

* don't wait for 47 years if clock is mismatched

* mv offline folder to www so it doesn't conflict with branch name

* only release the wifi IP/route if it's from DHCP

* whitepace

* print Connected to Bluetooth with IP:

* consistency

* display wifi is not connected if no SSID

* whitepace

* consistency

* whitepace

* consistency

* whitepace

* print unassigned if no

* reorder and print local wifi/BT IPs separately

* syntax

* print name of phone we're connected to with Bluetooth

* only run check_ip once

* print start/finish times

* don't try to dhcp_renew when running hostapd

* print when PUBLIC_IP not found

* fix return code

* don't renew wlan0 IP/route if it's failing

* logging

* syntax

* don't wifi_dhcp_renew if bad_wifi

* f we can't connect via BT, might as well try previously bad wifi networks again

* remove extra -HotSpot from SSID

* disconnect bnep0 even w/o an IP

* temporarily disable hotspot for 1m every hour to allow it to try to connect via wifi again

* download carbhistory to carbhistory.json.new and mv it over if valid

* egrep quietly

* download ns-temptargets to .new and mv it over if valid

* oref0-autosens-loop

* log why we're running autosens twice

* oref0-autosens-loop

* Add a note with the latest calculated IOB after boluses. (#770)

This is useful when multiple small micro boluses are being
administered. The notes will be visible in the pushover notifications from
nightscout.

* Disable wide_bg_target_range by default (#768)

* make wide_bg_target_range: false by default

* log target range when using wide_bg_target_range

* syntax

* Update openaps-install.sh (#778)

Add ntpdate

* Fix oref0-autotune-recommends-report for DST (#779)

* Build time_list array without using 'date' so it works with DST

* leading zeros

* only display API_SECRET not set warning if autotune fails (#774)

* set >30m zero temps when needed for low minGuardBG (#783)

* Optimize oref0-pump-loop, and bug fixes (#772)

* standardize on openaps report invoke

* not-yet-tested refactoring of monitor-pump, meal.json, etc.

* more refactoring for speed

* redirect output to the right files

* don't display full traceback on time set errors

* only run refresh_ commands if we don't have new glucose data yet

* remove end-of-line whitespace

* update pump_loop_completed before glucose-fresh checks

* reset pump clock if >55s off; better error messaging

* syntax

* nest ifs so we quit immediately if fresh

* hide red-herring 'date: invalid date ‘@’' message

* don't redirect oref0-meal stderr to meal.json

* more accurate log message

* show monitor/status.json if it's bolusing

* allow bolus and bolus wizard timestamps to differ by 1 second

* boluswizard uses current.carb_input not current.carbs

* warn if Treatment carbs unclassified

* profile.A52_risk_enable variable reference

* don't wait_for_bg after a Warning

* replace () with { ;}

* use try and retry functions

* retry basal_profile.json pull if it fails

* Couldn't

* curly braces and clearer error

* syntax

* exclude .pyc files from git

* lots more try, move suspended check to fail function

* log when Reducing insulinReq for expectedDelta

* try inside smb_suggest

* grammar

* wait_for_bg if too old; clarify error messages

* not sure how that got removed

* touch pump_loop_completed to wait for a new BG

* newlines

* check that profile has a valid current_basal

* differentiate things we can continue from if they fail

* "grep: enact/smb-suggested.json: No such file or directory" is not useful

* rename refresh_pumphistory_and_meal for error clarity

* continuing

* "grep: enact/smb-suggested.json: No such file or directory" is not useful

* install ntpdate

* only show reason too old if it's recent

* make sure status.json is fresh before checking if it says pump is suspended

* use try_return to more clearly log when ESC or bolus fails

* move calculate_iob into merge_pumphistory as it requires pumphistory-merged.json

* syntax

* 0.6.0-dev6

* if insulinReq > 0 but not enough for a microBolus, don't set an SMB zero temp (#786)

* Add some missing units conversion in reason field.

Some unit conversion were missing in the reason field, addede them.
Also changed some of the console messages.

* Add Carb ratio to reason field.

This is useful as it allows to clearly see that what is really used for the
calculation, and might avoid incorrectly thinking that the pump settings
are used when autotune is active.

* only add extra negative deviations if exercise mode is set (#790)

*  don't reduce insulinReq for expectedDelta (we have minGuardBG for that) (#793)

* log when Reducing insulinReq for expectedDelta

* don't reduce insulinReq for expectedDelta (we have minGuardBG for that now)

* comment out tests for behavior being removed

* run autotune 4am-4am instead of midnight-midnight (#794)

* run autotune 4am-4am

* run autotune at 4am instead of midnight

* gzip old autotune json and log files to save space (#792)

* gzip old autotune json and log files to save space

* force gzip to overwrite if necessary

* figure out how to not gzip the log we're currently writing to

* only gzip autotune log files more than 2 days old

* *** WARNING *** DO NOT USE enableSMB_always or enableSMB_after_carbs with xDrip+, Libre, or similar (#690)

* Restore 512/712 support (#775)

* standardize on openaps report invoke

* not-yet-tested refactoring of monitor-pump, meal.json, etc.

* more refactoring for speed

* redirect output to the right files

* don't display full traceback on time set errors

* only run refresh_ commands if we don't have new glucose data yet

* remove end-of-line whitespace

* update pump_loop_completed before glucose-fresh checks

* nest ifs so we quit immediately if fresh

* hide red-herring 'date: invalid date ‘@’' message

* don't redirect oref0-meal stderr to meal.json

* more accurate log message

* show monitor/status.json if it's bolusing

* allow bolus and bolus wizard timestamps to differ by 1 second

* boluswizard uses current.carb_input not current.carbs

* warn if Treatment carbs unclassified

* profile.A52_risk_enable variable reference

* don't wait_for_bg after a Warning

* don't run 512-incompatible currenttemp check w/o microBolusAllowed

* run old_main for 512/712 pumps

* fail preflight and quit main() if we detect an x12 pump

* use die instead of fail to prevent mmtuning on x12 pumps

* update openaps-install for Pi (#791)

* make openaps-install work for Pi

* more pi stuff

* python-software-properties is now software-properties-common

* use openaps-packages.sh

* require a NS site when running interactively

* ask for NS URL even if NIGHTSCOUT_HOST env var is set

* clarify that tokenauth has to already be set up in NS

* enumerate CGM options in detail

* explain first, then use short prompts

* require/reprompt for SN and API_SECRET

* Cancel high temps and shorten long zero temps when we lose CGM data (#796)

* put too-old-BG stuff together

* move BG too old check in with CGM error checks; shorten long zero temps

* use 12m for old BG threshold instead of 10m

* 0.6.0-rc1

* merged pi-install to dev

* oref0-pump-loop logging improvements (#800)

* print when Retrying a command

* remove duplicate old function monitor_pump

* don't print traceback when Couldn't refresh pumpprofile

* stringify status.json

* wait 15-30s for boluses to finish

* Fix "A52_risk_enable is not defined" error (#805)

* only try to get bnep0 IP if bt-pan succeeds (#803)

* only try to get bnep0 IP id bt-pan succeeds

* disable_hotspot every 20m to check for wifi

* if suggested temp is more than 20m shorter, enact it (#804)

* Delete profile.carbratio_adjustmentratio (#798)

This parameter is dangerous when used with autotune and
doesn't have the expected or described results.

Remove for now. (Docs will also need to be adjusted)

* retry bad_wifi after an hour (#806)

* print when Retrying a command

* remove duplicate old function monitor_pump

* don't print traceback when Couldn't refresh pumpprofile

* stringify status.json

* wait 15-30s for boluses to finish

* install bash-completion

* retry bad_wifi after an hour

* fix logic error in maxDelta (#807)

* fix basal schedule error checking (#808)

* validate pumpprofile.json.new before using

* fix current_basal check

* don't print filename

* show the right file

* 0.6.0-rc2

* Convert threshold where appropriate in logging output (#811)

* log-smb-disabled

* require boolean true on enableSMB preferences (#812)

* add MDT to oref0-ns-loop

* add MDT to oref0-ns-loop

* add logging data

* Fix log error

* 0.6.0

* 0.6.1-dev

* don't re-install if we already have 0.6.1

* Check OREF0_SRC env for source code location. Check for being behind upstream. Only warn if repo is ahead of local (not local ahead of remote) (#822)

* fix whitespace (convert tabs to spaces) and log messages

* test small commit

* js cleanup start
changed splice/pop to array element
cleaned up ns-status

* splice pop format

* changed var declaration

* oref0-version fetch upstream (#825)

* Check OREF0_SRC env for source code location. Check for being behind upstream. Only warn if repo is ahead of local (not local ahead of remote)

* Need to actually git fetch upstream

* Update oref0-version.sh

Clarify error message

* Process the Meal marker event from medtronic pump (#832)

* Process the Meal marker event from medtronic pump (#810)

* Changes

* Process Meal Markers from pump

* Undo changes

* tabs to spaces to fix indentation

* return journalCarbs

* copy-pasta fix

* indentation

* Improve the oref0-pump-loop debuging options by adding a debug flag. (#826)

* Improve the oref0-pump-loop debuginng options by adding a debug flag.

* Grammar

* commenting out unused and incorrect prepped_glucose code (#828)

* commenting out unused and incorrect prepped_glucose code

* remove second (yet) for consistency

* remove second (yet) for consistency

* not above means <=

* use pumpbasalprofile for autotune IOB calculations (#818)

* abort setup if we can't install bc etc. (#835)

* Basal record search (#834)

* Basal record search (#819)

* Changes

* Search through pump history for basal duration records

* undoing some changes

* Missed variable rename

* Attempt to fix failing tests, they're referring to 'date' not 'timestamp'

* loop over all of pumpHistory to find matching TempBasalDuration if it's not adjacent

* fix whitespace (tabs and trailing spaces)

* also edit settings.json and bg_targets_raw.json during setup (#815)

* Simple Remote Access Scripts (#817)

regenerate-index.sh creates a new file index.html every time it is run.  This contains simple html formatting with example data for now (intent is to add additional parameter-value pairs for display after approval of proof of concept).
setup-http.sh is intended to be called from oref0-setup.sh and adds cron entries to start SimpleHTTPServer at reboot and run regenerate-index.sh periodically.  Both files should be in ~/myopenaps/enact directory.  From a browser on any device, browse to http://[RIG_IP_ADDRESS]/index.html and the page will self-refresh periodically.

* only calculate UAM deviations for the last ~30m (#829)

* Fix typo in setup script for 512 files (#861)

* Fix typo in setup script for 512 files

Script currently saves 'bg_targets_raw.json' as 'bg_targets_raw.json,'

Remove the errant comma at the end of the output file name.

* Fix the other one too

* don't require enableSMB to enableUAM (#831)

* oref0-setup Explorer HAT support (#830)

* ask about Explorer Board HAT

* install explorer-hat branch of spi-serial for spidev0.0

* merged pi-install to dev

* pi user

* switch to decocare-clean

* enable spidev ports on the Pi

* try using packaged bluez with Rapsbian

* force apt to use IPv4 for now

* set bluetoothdminversion=5.43 to use packaged bluez with Rapsbian

* Revert "switch to decocare-clean"

This reverts commit 77dbd8a020534e30619c52316be836296832e190.

* switch to oref0/master for bin/openaps-packages.sh

* only use splitHistory internally: return un-split tempHistory (#836)

* fix Edison batteryVoltage (#837)

* refresh edison batteryVoltage

* don't rely on openaps battery-status alias

* don't require Explorer Board to use EdisonVoltage

* Allow Custom OPENAPS_DIR (#858)

* Allow Custom OPENAPS_DIR

* Fixed the dev oref0-pump-loop script to drop x12-incompaitble reports… (#862)

* Fixed the dev oref0-pump-loop script to drop x12-incompaitble reports IF an x12 pump is detected

In previous versions of oref0, this action was done by manually implementing an alias-change (as documented in past versions of the oref0 code).

Since the code here is not done via an alias anymore, but rather spelled out in the script, an if/then/else block is required to remove the offending reports when an incompatible pump is detected. 

Tested and verified against my 712.

* Update oref0-pump-loop.sh

Added -q to grep, we don't need to re-print the model num

* Restore newline before comment.

* Serve offline web page with flask (#843)

* Automate the steps to install flask as a service (#839)

Automate the steps to install flask as a service so can monitoring your rig OFFLINE with an Offline web page

IPHONE USERS To access this from an iphone browser, enter something like the following: http://172.20.10:5000

ex : http://IP_address__rig:5000

* use port 8080 for flask to avoid conflicts

* add meta refresh and title

* should we add a flask.log? (#850)

* added check for custom OPENAPSDIR enviornment var (#851)

* added check for custom OPENAPSDIR enviornment var

* change environment variable to OPENAPS_DIR

* limit SMB zero temps to 60m (#844)

* New monitoring page on port 80 (#863)

* Automate the steps to install flask as a service

Automate the steps to install flask as a service so can monitoring your rig OFFLINE with an Offline web page

IPHONE USERS To access this from an iphone browser, enter something like the following: http://172.20.10:5000

ex : http://IP_address__rig:5000

* Automate the steps to install flask as a service (#839)

Automate the steps to install flask as a service so can monitoring your rig OFFLINE with an Offline web page

IPHONE USERS To access this from an iphone browser, enter something like the following: http://172.20.10:5000

ex : http://IP_address__rig:5000

* use port 8080 for flask to avoid conflicts

* add meta refresh and title

* Change the port of offline webpage to 5001

* Create new webpage offline to monitoring the rig. Change the port of FLASK to port 80.

* Create new webpage offline to monitoring the rig. Change the port of FLASK to port 80.

* should we add a flask.log? (#850)

* added check for custom OPENAPSDIR enviornment var (#851)

* added check for custom OPENAPSDIR enviornment var

* change environment variable to OPENAPS_DIR

* convert tabs to spaces

* show Sensitivity Ratio in topbox instead of BASAL T

* Add indexError.html to handle JSON Value error (#848)

* do #849 manually

* clearer error message

* allow smartphones to zoom out to see the whole page un-scrunched

* catch IOErrors too

* make BG black

* improve column layout

* display 4h past and future

* use suggested predBGs, not enacted

* display Temp Targets

* calculate and display BG delta

* syntax

* print BG delta correctly

* shorter chart forecast legends

* 70% scale; units

* more readability improvements

* Cancel temp on error and > 55m w/ skip_netural_temps (#842)

* whitespace cleanup

* don't ignore temp cancel requests

* cancel temp on error rather than setting neutral

* with skip_neutral_temps, cancel non-zero temps before the top of the hour

* move cancel-temp logic outside of eventualBG < min_bg

* smb_enact_temp if a 0 duration temp is requested

* ignore lastTemp/currenttemp mismatches if we have <10m old lastTemp data

* if currenttemp.duration is zero because temp is canceled it won't match lastTemp

* Update oref0-ns-loop.sh (#870)

Seems to fix issue #868 - fixes uploading with oref0-ns-loop on Pi

* Better error message for self-resolving error on bad pump reads (#871)

* raise BG target for noisy / raw CGM data (#833)

* use raw_safety_multiplier=0.75 instead of max_raw

* disable SMB on really big jumps for safety

* raise SMB-disable threshold to delta > 15% of bg

* 15% is too low

* re-enable max_raw (applied after raw_safety_multiplier adjustment)

* round insulinReq down to nearest 0.1U to safely allow eSMB on small basals

* Treat xDrip noise >= 3 similar to Dexcom showing ???

* neutral temp only for bg <= 10 || bg == 38

* Propagate the noise field. (#820)

Propagate the noise field of glucose data so it can be used by determine_basal.

* define vars

* pass noise to determine-basal; adjust target instead of BG

* let's merge #735 instead

* raw=noise; raise target 1.3x for noise; adjust maxraw accordingly

* rename rawTargetMultiplier to noisyCGMTargetMultiplier

* update unit tests

* check noise and cancel/shorten temps if needed

* fix test

* comment out broken CURL_AUTH API_SECRET line (#838)

* always enable autosens-loop (#841)

* Display seconds in SMB wait time (#846)

* Display seconds in SMB wait

* Fix regex and indentation

* Ignore records with 0 sgv (#865)

* Display RMS deviation in autosens (#867)

It can be difficult to evaluate whether changes to less-intuitive settings changes like insulin peak time/DIA are likely to be helpful.  By calculating RMS deviation in autosens we have a metric measuring how well the current settings are predicting observed values.  

A change reducing RMS error will likely improve results and a change increasing RMS error will likely be unhelpful.

* Allow Custom OPENAPS_DIR (#859)

* Automate the steps to install flask as a service (#839)

Automate the steps to install flask as a service so can monitoring your rig OFFLINE with an Offline web page

IPHONE USERS To access this from an iphone browser, enter something like the following: http://172.20.10:5000

ex : http://IP_address__rig:5000

* use port 8080 for flask to avoid conflicts

* add meta refresh and title

* Allow Custom OPENAPS_DIR

* Simplify environment variable check

* use curly brackets consistently

* removed merge indicators

* fix direction calculation for negative trending (#885)

* Speed up autotune and make it work in NS (#872)

* declare vars

* convert all lib references to relative for NS autotune compatibility

* trim down IOBInputs.history to just the data for 6h prior to BGDate

Conflicts:
	lib/autotune-prep/categorize.js

* remove commented unused code

* comment out some process.stderr.write

* Autotune: avoid raising basals from UAM (#875)

* exclude >6mg/dL deviations as UAM; only add lowest 50% of UAM deviations to basals

* trim down IOBInputs.history to just the data for 6h prior to BGDate

* remove commented unused code

* remove duplicate function definitions (#892)

* run bg_targets.json after bg_targets_raw.json

* Upgrade bluez to 5.48, start bluetoothd if it's not running, remove experimental (#876)

* - bugfix: also start bluetoothd in oref0-bluetoothup if it's not running
- upgrade bluez to 5.48, changelog http://www.bluez.org/release-of-bluez-5-48/
- remove --experimental (finally) on bluetoothd startup and change it in /etc/rc.local if it's still there

* fix grep statement

* Explorer hat auto install (#897)

* Update oref0-setup.sh

* Update oref0-setup.sh

* Update oref0-setup.sh

* moving installer and code cleanup

* Update oref0-setup.sh

* indentation

* auto-detect Explorer HAT

* only generate edison-battery.json on edisons

* support openaps-menu/scripts/getvoltage.sh

* Remove external repo (#898)

* grep quietly

* Update logrotate.rsyslog (#901)

* apt-get update, upgrade, and autoclean

* re-do timerun stuff against dev (#896)

* allow pumphistory pull to take 90s (for pi0w)

* don't start oref0-pump-loop every 30s (#893)

* Fixed autotune_isf_adjustmentFraction. (#905)

* proceed to add battery-status if it doesn't exist yet

* do not produce errors when iob_data.lastTemp doesn't exist (#883)

* Pushover Priority to Urgent (#873)

* Pushover Priority to Urgent

Set Pushover Priority to urgent to ensure user sees the message.

* Updated to provide pushover preferences

Added preferences to allow user to configure pushover alerts' sound, priority, snooze, and only for options.

* Date error with MDT CGM (#845)

* Use proper date field in glucose-fresh for MDT CGM data

* Fix Typo ($ to &)

* In glucose-fresh Use display_time if present, otherwise use date

* Forgot the filename in bin/oref0-pump-loop change

* Format Autotune Output Profile (#900)

* Format autotune output when copying it to settings.

* Replaced json command calls with equivalent jq command calls.

* Placed autotune profile format in a better place.

* Added jq . -M back in for the grep for start command.

* Reverted the cat with a redirect back to a cp command.

* Removed unnecessary -M option to jq.

* Format new autotune profile with json-stable-stringify so it is
consistently arranged from one day to the next.

* Autotune Command Line Option to Classify UAM as Basal (#904)

* Added optional flag to oref0-autotune for manually telling
categorize to include all of the UAM periods as basals.
This is essentially telling autotune that the user
faithfully entered all of the carb intakes for the time
being processed.

* Handled variable arguments better.

* Prioritize categorize_uam_as_basal flag over the too many deviations categorizes as UAM check.

*  Offline monitoring page to show in mmol (#891)

* Offline monitoring page to show in mmol

* tabs to spaces

* Fixed time zone problem. (#910)

* Opened lsgaps time window from 5 to 6 to account for small variations (#915)

greater than 5 minutes with G5 and xdrip-js.

* print enact/smb-suggested.json if deliverAt check fails (#895)

* Pushover glances (#856)

* Adding watch complications - glances to pushover

Pushover has a new powerful glances API that sends complications to an apple watch or small bits of data to a smart watch face. More information at the following web page: https://pushover.net/api/glances

This change enhances the pushover notification script to optionally send information to the pushover glances API for watch face updates once every 10 minutes. It works well for apple watch complications. It has not yet been tested for android wear watchface updates yet.

Note that apple limits the daily total number of complication updates to save watch battery, so we cannot update this glance data more often than every 10 minutes today.

* Update oref0-pushover.sh

* refactor for simplicity performance plus ifttt

Refactored for simplicity and performance to just read from enact/smb-suggested.json

Also, added another optional notification that will send an ifttt maker event "carbs-required" if additional carbs are required and if environment variable "MAKER_KEY" is set. This is the ifttt webhooks Maker key https://ifttt.com/maker_webhooks
The "carbs-required" event can then be used with a ifttt recipe to perform an action based on carbs required. A good use case is to use the ifttt phone action to get a phone call with this event that will read out in human language the additional carbs and other vital facts. It will leave a voice mail if not answered

* fix cut-n-paste error

* fix bug with delta & tick to remove +

* only use suggested.json - not smb-suggested.json

* fixed problem with delta comparisons

* fix delta comparisons

* Language tweaks

* exit if enact > 5 mins for safety and mult rigs

* refactored to use glucose.json trend values

* cut-n-paste error fixes

I don't think cut-n-paste works in the github editor. Somehow it put 4 copies of my one code change throughout the file. I cleaned that up.

* removed quotes from lastDirection value

* fix syntax error

* carbs-required repeat changed from 15 to 60 min

Changed the carbs-required repeat check to send this maker notification no more than once per every 60 minutes. By that time, the user should have eaten and logged some carbs. IFTTT limits phone call triggers to 100 per month.

* set positive deviations to zero if BG is below 80 (#902)

* set positive deviations to zero if BG is below 80 (#903)

* Fix iob calculation error (#878)

* Fixed the calculation error where different DIAs are used when
user has pump set to a value lower than 5 hours.

* Fixed to use adjusted dia value instead of original profile setting.

* Reordered calcIOB arguments.

* Added explanatory comment.

* Added unit test to ensure 5 hour minimum DIA is being
correctly enforced for rapid acting insulin.

* Fixed logic to move IOB test after profile DIA.

* Enable IOB calc to recognize suspends (#879)

* Added initial code to collect suspend and resume events.

* Initial implementation of treating suspends as zero basals.

* Added duration assignments back.

* Declared splitEvents variable and removed some debug.

* Used a similar structure to split suspends as with basals.

* Made some whitespace match previous version.

* Fixed call to splitAroundSuspends that was missing an argument.

* Added profile setting to enable new feature.

* Fixed incorrect comment description

* Fixed logic error for when there were no suspends or resumes in the history.

* Added test for iobcalc accounting for pump suspends.

* Added a couple of new tests for pump suspend interaction.
Split the test into multiple "it should.." test.

* Added a note for an additional test that needs to be written

* Modified code to add zero temps while pump is suspended.
Modified test to account for corrected logic of zero temping
while pump is suspended. Added remaining test.

* Cleaned up some comments.

* Clarified a comment.

* Updated a comment.

* #884: default remainingCATime to remainingCATimeMin if meal_data.carbs == 0 (#916)

* Fix suspend zeros iob preference (#918)

* Fixed suspend_zeros_iob preference.

* Fixed preference name.

* remove old commented code and corresponding usage entry

* Fix a href (#926)

* Changed suspend_zeros_iob default to true. (#922)

* Fix handling of dates so that we are not comparing the time the pump-… (#924)

* Fix handling of dates so that we are not comparing the time the pump-clock *was* set to, to the time it is when the test executes. Also, fix set-device-clocks so that it doesn't try and set the 'clock' on xdrip CGM.

Reset author on new device.

* Update oref0-pump-loop.sh

* Update oref0-pump-loop.sh

* Consistent use of `$HOME` instead of `~`. Make it possible to install oref0 in another directory than `myopenaps`  and make it possible to start it from any directory (#886)

* oref0-setup.sh installed myopenaps in the current directory instead of using $HOME/myopenaps
also found missing instance where hardcoded ~/myopenaps was still used

* use $HOME/ instead of ~/

* syntax fixes

* Revert "syntax fixes"

This reverts commit 3ff3b6c99efadff71b55c83aedf700e9cc1164c0.

* Revert "Fix handling of dates so that we are not comparing the time the pump-… (#924)"

This reverts commit 254757b7614cf977539594722ddba0d0e2b24db9.

* Update oref0-setup.sh for the edgecase of failed wget (#909)

* Update oref0-setup.sh

remove existing `bluez-5.48.tar.gz` in case of failed wget so subsequent commands run.

* Update oref0-setup.sh

* Update oref0-setup.sh

* Generate settings/bg_targets.json for x12 models (#920)

settings/bg_targets.json is generated from settings/bg_targets_raw.json, adding the user-preferred units, and pulls no data from the pump.

* Update offline monitoring page (#923)

* Offline monitoring page to show in mmol

* tabs to spaces

* offline monitoring page

* Read BG data till out of date range for chart

* center data in BG pill

* various fixes, move to all ajax calls

* refactor calculate.js (#931)

* remove error function (never used) from code

* parallel coefficient order and precision

* remove variable that is never used

* remove references to biobContrib

* remove incorrect comment

* remove timeRef variable

* remove unnecessary comment

* parallel results syntax

* improve readability of bilinear formulas

* line spacing

* round time since bolus for bilinear, similar to exponential calcs

* rename vars, add comments

* move function

* remove unnecessary condition in iobCalcBilinear

* create iobCalcExponential function

* delete some blank lines

* more line spacing tweaks

* change td to end in exponential function

* change tp to peak in exponential function

* reverse logic for using custom peak time

* calc minutes since bolus outside bilinear and exponential functions

* reverse activityContrib and iobContrib vars

* change 60*3 to end in bilinear function

* flip logic for treatment.insulin condition

* whoops. left a return statment in there.

* reverse order of functions in file

* set default dia, peak, and end as constants; add comments

* comments and source for exponential formula

* another comment

* iobCalcBiLinear to iobCalcBilinear

* delete line break in comment

* parentheses for clarity

* peak then end

* Comments

* comment tweaks

* comments and more intuitive calcs for activityContrib in iobCalcBilinear function

* narrow variable scope in iobCalcExponential

* 35 and 120, inclusive

* revert let back to var

* Fix date routine, corrected/operational (#933)

* Fix handling of dates so that we are not comparing the time the pump-clock *was* set to, to the time it is when the test executes. Also, fix set-device-clocks so that it doesn't try and set the 'clock' on xdrip CGM.

Reset author on new device.

* Update oref0-pump-loop.sh

* Update oref0-pump-loop.sh

* Update oref0-pump-loop.sh

* Update oref0-pump-loop.sh

* Fix syntax errors & unhandled errors in prior date-routine fix

* Update oref0-pump-loop.sh

* Update oref0-pump-loop.sh

* only kill bluetoothd on edison

* Revert "Fix date routine, corrected/operational (#933)"

This reverts commit 5f29a885265d51fd2f6e17855dab84d5eff40090.

* Don't loop on "stuck" CGM data (#942)

* don't loop on 'stuck' CGM data

* add reason field; fix var

* make sure at least one avgdelta is non-zero

* offline monitor - use xdrip bg data if more recent than monitor (#947)

* Slightly refactor oref0 meal to read all the data before (#954)

* Slightly refactor oref0 meal to read all the data before
trying to match bolus wizard entries to corresponding
bolus entries.

This allows out of order bolus and bolus wizard entries to
still work correctly.

Before this change, when the bolus entry was after the bolusWizard
entry, the carb was being skipped because no corresponding
bolus was seen.

* BolusWizard with matching bolus entry following it should not bet skipped.

* eleborate "skipping bolus wizard entry" information

(cherry picked from commit f628f49c11954d3672d7846e12b392b96cf1fd56)

* remove extra spaces

(cherry picked from commit eff86b5f55900bce428ee8b54480331e5cbca670)

* one more space removed

(cherry picked from commit fbcd8f23d65e071fb39c27671d19d7e6c7f94264)

* Fix log rotate for those who don't use boostrap

* Fix log rotate (dev PR) (#963)

* Fix a href (#926)

* Fix log rotate for those who don't use boostrap

* rigs start at weekly by default

* Change comment

* backport carelink support by supressing mmtune execution (#964)

* Support for x12 models in main() (#948)

* Initial commit for x12 support in main()

Deprecates old_main() and old functions that use it. Adds support for x12 pumps in smb loop (without using SMBs). ***Not tested.***

* Allow x12 models to use SMB loop

* Remove redundant check and quiet grep

* Readability

Adds parentheses to x12 SMB warning.

* Log clarity

Changes based on comments in #948

* Fix log rotate for those who don't use boostrap (#962)

* Change nano to vi for edit-wifi shortcut

* Remove update_config=1 from bootstrap script

* re-apply 7051259fc2fdb2fc3434f8c3a5d19130c01f8fba

* avoid filling logs with DIA warning, since we override to 5h now anyway (#976)

* Try three times to get a Bluetooth IP address

When my phone is in and out of service several times in as many minutes (between subway stations, for example) it doesn't assign an IP address to the device when it tries to connect via Bluetooth. Once back in a more stable environment it takes a while before it tries to get on the Internet via Bluetooth again. This change, tested over several weeks, significantly reduces the time offline during and after using the subway.

* Fix typo in filename of /tmp/autosens-completed (#990)

Fix a typo that would cause completed_recently in oref0-autosens-loop.sh to always be false. This effectively disabled a feature that was supposed to make autosens recalculation happen less frequently when under high load.

* Revert change (#991)

Revert the outcome of this test to its original behavior.

* don't error when HAT file doesn't exist

* autoconfirm apt-get

Add -y flags to the rest of the apt-get commands to bypass y/n prompts.

* Don't error when HAT file doesn't exist (#993)

Same issue as last, different location.

* fix improper revert

* if targets are < 20, assume for safety that they're intended to be mmol/L (#995)

* make maxUAMSMBBasalMinutes a preference (#974)

* Change invalid-IOB-curve behavor to match message (#1003)

* 0.6.1

* tabs to spaces

* add sgv.json?count=# route (#1001)

* add sgv.json?count=# route

support similar to xdrip+, for offline use with watchfaces, etc.

* add units_hint to sgv.json

* Trying to update the 'clock' on xdripaps causes an un-needed loop fail (#1002)

Stop trying to set-device-clocks for CGM on xdripaps installs.
When this command is executed, it results in a loop failure due to 'failure' to set the pump clock.

Fixed by looking for the xdrip.ini file & skipping the CGM clock update if it is found.

* Removing old to-do that's been taken care of

* Remove seemingly unused comments

* Add radio_type=carelink in pump.ini for carelink installs

* Update index.js (#1012)

* Update index.js

Fix to warning message indicating Xdrip+ version is handling noisy data appropriately.

* clarify

* Fixed currentRate calculation when using autosens. (#1019)

* fix syntax error (#1023)

I was getting syntax errors running `openaps-setup` and I putting this `fi` back fixed it: https://github.com/openaps/oref0/commit/f92a01ead0e5186270920b27d61d2282d178569c#diff-704a2fd9a43fd79bf52037b1668c146d

* adding duty cycle feature for carelink + mdt users (#1025)

* adding duty cycle feature for carelink + mdt users

* replace tab with 4 space

* minor tweaks, mostly for clarity

* update xDrip+ enableSMB warnings (#1017)

* Update index.js

Fix to warning message indicating Xdrip+ version is handling noisy data appropriately.

* clarify

* remove trailing spaces

* remove trailing spaces

* remove trailing spaces

* Revert "Removing old to-do that's been taken care of"

This reverts commit f92a01ead0e5186270920b27d61d2282d178569c.

Conflicts:
	bin/oref0-setup.sh

* only check_duty_cycle if "$DUTY_CYCLE" -gt "0"

* xdrip.ini always exists: check for xdrip/ dir instead

* Install MRAA on all kernel versions if it is needed. (#1015)

* 0.6.2-dev

* Adding links to documentation, and creating drop-down for readability

* Fixing link to modern docs, and recommending others ways to contribute

* Re-run apt-get update after dist-upgrade (#1034)

Fixes an issue where openaps-install.sh cannot find packages on the pi after running a dist-upgrade.

* rework release-master.sh

* 0.6.2

* Update openaps-packages.sh (#1054)

The latest node-js for raspbian deprecates the use of nodejs-legacy, which breaks this script on new pi installs. This will make it so that nodejs-legacy is only installed on the edison.

* Update issue templates

* Update issue templates

* Update issue templates

* Update issue templates

* Update issue templates

* Remove duplicate

* Remove duplicate

* Remove duplicate

* Update --individual-troubleshooting-help.md
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.

6 participants