From 5bbae1e47ca0081097f0328115fc4d061f228dc2 Mon Sep 17 00:00:00 2001 From: jaylagorio Date: Sun, 22 Apr 2018 11:28:35 -0400 Subject: [PATCH 01/23] 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. --- bin/oref0-online.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/oref0-online.sh b/bin/oref0-online.sh index 3ccc14303..bf7011394 100755 --- a/bin/oref0-online.sh +++ b/bin/oref0-online.sh @@ -118,7 +118,10 @@ function bt_connect { echo; echo "No Internet access detected, attempting to connect BT to $MAC" oref0-bluetoothup sudo bt-pan client $MAC -d - sudo bt-pan client $MAC && sudo dhclient bnep0 + for i in {1..3} + do + sudo bt-pan client $MAC && sudo dhclient bnep0 + done if ifconfig | egrep -q "bnep0" >/dev/null; then echo -n "Connected to Bluetooth with IP: " print_local_ip bnep0 From 2845d87146ee4f7c4d91a55e061e15a15532bd28 Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Tue, 15 May 2018 12:50:21 -0700 Subject: [PATCH 02/23] tabs to spaces --- bin/oref0-online.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/oref0-online.sh b/bin/oref0-online.sh index bf7011394..8240ad6cb 100755 --- a/bin/oref0-online.sh +++ b/bin/oref0-online.sh @@ -118,10 +118,10 @@ function bt_connect { echo; echo "No Internet access detected, attempting to connect BT to $MAC" oref0-bluetoothup sudo bt-pan client $MAC -d - for i in {1..3} - do + for i in {1..3} + do sudo bt-pan client $MAC && sudo dhclient bnep0 - done + done if ifconfig | egrep -q "bnep0" >/dev/null; then echo -n "Connected to Bluetooth with IP: " print_local_ip bnep0 From e8b261b92338498f53f6c94fbd525bd67e9fe452 Mon Sep 17 00:00:00 2001 From: tynbendad Date: Tue, 15 May 2018 13:55:59 -0600 Subject: [PATCH 03/23] 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 --- www/app.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/www/app.py b/www/app.py index e01687aff..add4199f7 100644 --- a/www/app.py +++ b/www/app.py @@ -1,7 +1,7 @@ import os import socket -from flask import Flask, render_template, url_for, json, jsonify +from flask import Flask, render_template, url_for, json, jsonify, request from datetime import datetime import pytz @@ -51,6 +51,23 @@ def glucose(): data = json.load(open(json_url)) return jsonify(data) +@app.route("/sgv.json") +def sgvjson(): + json_url = os.path.join("/root/myopenaps/settings/profile.json") + data = json.load(open(json_url)) + units = data['out_units'] + count = request.args.get('count', default = 10, type = int) + if os.path.getmtime("/root/myopenaps/xdrip/glucose.json") > os.path.getmtime("/root/myopenaps/monitor/glucose.json"): + json_url = os.path.join("/root/myopenaps/xdrip/glucose.json") + else: + json_url = os.path.join("/root/myopenaps/monitor/glucose.json") + data = json.load(open(json_url)) + if units == "mg/dL": + data[0]['units_hint'] = "mgdl" + else: + data[0]['units_hint'] = "mmol" + return jsonify(data[0:count]) + @app.route("/temptargets") def temptargets(): json_url = os.path.join("/root/myopenaps/settings/temptargets.json") From 244644057b8867b15f2506131eb48d4e5b932857 Mon Sep 17 00:00:00 2001 From: Dave Acklam Date: Tue, 15 May 2018 14:56:20 -0500 Subject: [PATCH 04/23] 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. --- bin/oref0-set-device-clocks.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/oref0-set-device-clocks.sh b/bin/oref0-set-device-clocks.sh index 7ad8f4523..b635ba070 100755 --- a/bin/oref0-set-device-clocks.sh +++ b/bin/oref0-set-device-clocks.sh @@ -47,6 +47,10 @@ if checkNTP; then sudo ntpdate -s -b time.nist.gov echo Setting pump time to $(date) openaps use $PUMP set_clock --to now 2>&1 >/dev/null | tail -1 - echo Setting CGM time to $(date) - openaps use $CGM UpdateTime --to now 2>&1 >/dev/null | tail -1 + # xdripaps CGM does not have a clock to set, so don't try. + if [ ! -f xdrip.ini ] + then + echo Setting CGM time to $(date) + openaps use $CGM UpdateTime --to now 2>&1 >/dev/null | tail -1 + fi fi From f92a01ead0e5186270920b27d61d2282d178569c Mon Sep 17 00:00:00 2001 From: Dana Lewis Date: Fri, 18 May 2018 09:42:41 -0700 Subject: [PATCH 05/23] Removing old to-do that's been taken care of --- bin/oref0-setup.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index e05e4e82a..ea441342f 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -858,11 +858,6 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then # See https://github.com/oskarpearson/mmeowlink/issues/51 or https://github.com/oskarpearson/mmeowlink/wiki/Non-USA-pump-settings for details # use --ww_ti_usb_reset=yes if using a TI USB stick and a WW pump. This will reset the USB subsystem if the TI USB device is not foundTI USB (instead of calling reset.py) - # Hack to check if radio_locale has been set in pump.ini. This is a temporary workaround for https://github.com/oskarpearson/mmeowlink/issues/55 - # It will remove empty line at the end of pump.ini and then append radio_locale if it's not there yet - # TODO: remove once https://github.com/openaps/openaps/pull/112 has been released in a openaps version - grep -q radio_locale pump.ini || echo "$(< pump.ini)" > pump.ini ; echo "radio_locale=$radio_locale" >> pump.ini - fi fi # Medtronic CGM From a04f48f6c097c765cf23fc345985a6c261212561 Mon Sep 17 00:00:00 2001 From: Dana Lewis Date: Fri, 18 May 2018 09:43:25 -0700 Subject: [PATCH 06/23] Remove seemingly unused comments --- bin/oref0-setup.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index ea441342f..47e475c79 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -852,12 +852,6 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then echo -n "Cloning subg_rfspy: " (cd $HOME/src && git clone https://github.com/ps2/subg_rfspy) || die "Couldn't clone oref0" fi - - # from 0.5.0 the subg-ww-radio-parameters script will be run from oref0_init_pump_comms.py - # this will be called when mmtune is use with a WW pump. - # See https://github.com/oskarpearson/mmeowlink/issues/51 or https://github.com/oskarpearson/mmeowlink/wiki/Non-USA-pump-settings for details - # use --ww_ti_usb_reset=yes if using a TI USB stick and a WW pump. This will reset the USB subsystem if the TI USB device is not foundTI USB (instead of calling reset.py) - fi # Medtronic CGM From 9f593c38dfcb156a0e49035a563b8a2843d8724c Mon Sep 17 00:00:00 2001 From: Dana Lewis Date: Fri, 18 May 2018 09:47:01 -0700 Subject: [PATCH 07/23] Add radio_type=carelink in pump.ini for carelink installs --- bin/oref0-setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 47e475c79..918d10135 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -835,6 +835,8 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then ( killall -g openaps; killall -g oref0-pump-loop) 2>/dev/null; openaps device remove pump 2>/dev/null if [[ -z "$ttyport" ]]; then openaps device add pump medtronic $serial || die "Can't add pump" + # add carelink to pump.ini + grep -q radio_type pump.ini || echo "radio_type=carelink" >> pump.ini # carelinks can't listen for silence or mmtune, so just do a preflight check instead openaps alias add wait-for-silence 'report invoke monitor/temp_basal.json' openaps alias add wait-for-long-silence 'report invoke monitor/temp_basal.json' From a0646d45a20500ac71fb7e54c45345c397d75a4c Mon Sep 17 00:00:00 2001 From: JELCRAWFORD Date: Fri, 18 May 2018 15:42:40 -0600 Subject: [PATCH 08/23] Update index.js (#1012) * Update index.js Fix to warning message indicating Xdrip+ version is handling noisy data appropriately. * clarify --- lib/profile/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/profile/index.js b/lib/profile/index.js index 5b6b87e53..5f347ca43 100644 --- a/lib/profile/index.js +++ b/lib/profile/index.js @@ -40,13 +40,16 @@ function defaults ( ) { , A52_risk_enable: false , enableSMB_with_COB: false // enable supermicrobolus while COB is positive , enableSMB_with_temptarget: false // enable supermicrobolus for eating soon temp targets - // *** WARNING *** DO NOT USE enableSMB_always or enableSMB_after_carbs with xDrip+, Libre, or similar - // xDrip+, LimiTTer, etc. do not properly filter out high-noise SGVs + // *** WARNING *** DO NOT USE enableSMB_always or enableSMB_after_carbs with Libre or similar + // LimiTTer, etc. do not properly filter out high-noise SGVs. xDrip+ builds greater than or equal to + // version number d8e-7097-2018-01-22 provide proper noise values, so that oref0 can ignore high noise + // readings, and can temporarily raise the BG target when sensor readings have medium noise, + // resulting in appropriate SMB behaviour. Older versions of xDrip+ should not be used with enableSMB_always. // Using SMB overnight with such data sources risks causing a dangerous overdose of insulin // if the CGM sensor reads falsely high and doesn't come down as actual BG does , enableSMB_always: false // always enable supermicrobolus (unless disabled by high temptarget) , enableSMB_after_carbs: false // enable supermicrobolus for 6h after carbs, even with 0 COB - // *** WARNING *** DO NOT USE enableSMB_always or enableSMB_after_carbs with xDrip+, Libre, or similar + // *** WARNING *** DO NOT USE enableSMB_always or enableSMB_after_carbs with Libre or similar. , allowSMB_with_high_temptarget: false // allow supermicrobolus (if otherwise enabled) even with high temp targets , maxSMBBasalMinutes: 30 // maximum minutes of basal that can be delivered as a single SMB with uncovered COB , maxUAMSMBBasalMinutes: 30 // maximum minutes of basal that can be delivered as a single SMB when IOB exceeds COB From 595159d4c165d01aec99ffe116529b52aab75411 Mon Sep 17 00:00:00 2001 From: Jeremy Cunningham <34543464+jpcunningh@users.noreply.github.com> Date: Tue, 22 May 2018 13:15:06 -0500 Subject: [PATCH 09/23] Fixed currentRate calculation when using autosens. (#1019) --- lib/iob/history.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iob/history.js b/lib/iob/history.js index 02441bc6b..681f4d345 100644 --- a/lib/iob/history.js +++ b/lib/iob/history.js @@ -513,7 +513,7 @@ function calcTempTreatments (inputs, zeroTempDuration) { //process.stderr.write("Autosens ratio: "+sensitivityRatio+"; "); } if ( sensitivityRatio ) { - currentRate = profile_data.current_basal * sensitivityRatio; + currentRate = currentRate * sensitivityRatio; } var netBasalRate = currentItem.rate - currentRate; From 6ba105de575d03aaedfee5d2ab416d71a99c2a32 Mon Sep 17 00:00:00 2001 From: Benjamin Ortega Date: Tue, 29 May 2018 14:26:15 -0500 Subject: [PATCH 10/23] 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 --- bin/oref0-setup.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 918d10135..76df68c68 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -847,13 +847,14 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then openaps alias add wait-for-silence '! bash -c "(mmeowlink-any-pump-comms.py --port '$ttyport' --wait-for 1 | grep -q comms && echo -n Radio ok, || openaps mmtune) && echo -n \" Listening: \"; for i in $(seq 1 100); do echo -n .; mmeowlink-any-pump-comms.py --port '$ttyport' --wait-for 30 2>/dev/null | egrep -v subg | egrep No && break; done"' openaps alias add wait-for-long-silence '! bash -c "echo -n \"Listening: \"; for i in $(seq 1 200); do echo -n .; mmeowlink-any-pump-comms.py --port '$ttyport' --wait-for 45 2>/dev/null | egrep -v subg | egrep No && break; done"' if [[ ${radio_locale,,} =~ "ww" ]]; then - if [ -d "$HOME/src/subg_rfspy/" ]; then - echo "$HOME/src/subg_rfspy/ already exists; pulling latest" - (cd $HOME/src/subg_rfspy && git fetch && git pull) || die "Couldn't pull latest subg_rfspy" - else - echo -n "Cloning subg_rfspy: " - (cd $HOME/src && git clone https://github.com/ps2/subg_rfspy) || die "Couldn't clone oref0" - fi + if [ -d "$HOME/src/subg_rfspy/" ]; then + echo "$HOME/src/subg_rfspy/ already exists; pulling latest" + (cd $HOME/src/subg_rfspy && git fetch && git pull) || die "Couldn't pull latest subg_rfspy" + else + echo -n "Cloning subg_rfspy: " + (cd $HOME/src && git clone https://github.com/ps2/subg_rfspy) || die "Couldn't clone oref0" + fi + fi fi # Medtronic CGM From 5d632b47f86f6ee8127012ada227484a4872a716 Mon Sep 17 00:00:00 2001 From: Jens Heuschkel Date: Sat, 2 Jun 2018 21:31:05 +0200 Subject: [PATCH 11/23] 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 --- bin/oref0-pump-loop.sh | 80 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/bin/oref0-pump-loop.sh b/bin/oref0-pump-loop.sh index 1b412e771..ed3a4b937 100755 --- a/bin/oref0-pump-loop.sh +++ b/bin/oref0-pump-loop.sh @@ -29,6 +29,7 @@ fi # main pump-loop main() { + check_duty_cycle prep if ! overtemp; then echo && echo "Starting oref0-pump-loop at $(date) with $upto30s second wait_for_silence:" @@ -110,6 +111,79 @@ function fail { exit 1 } +# The function "check_duty_cycle" checks if the loop has to run and it returns 0 if so. +# It exits the script with code 0 otherwise. +# The desicion is based on the time since last *successful* loop. +# !Note duty cycle times are set in seconds. +# +# Additionally it may start an "emergency action" if enabled. +# Possible actions are usb power cycling or reboot the system. +# The EMERGENCY_ACTION variable sets the allowable time between successful loops. +# If no loop has completed in that time, it performs the enabled actions. +# !Note to enable a emergency action use 0 to enable and 1 to disable +# +# The intention is two fold: +# First the battery consumption is reduced (Pump and Pi) if the loop runs less often. +# This is most dramatic for Enlite CGM, where wait_for_bg can't be used. +# Secondly, if Carelink USB is used with Enlite, and wait_for_silence can't be used, this +# prevents the loop from disrupting the communication between the pump and enlite sensors. +# +# Use DUTY_CYCLE=0 (default) if you don't want to limit the loop +# +# Suggestion for Carelink USB users are +# DUTY_CYCLE=120 +# EMERGENCY_ACTION=900 +# REBOOT_ENABLE=0 #0=true +# USB_RESET_ENABLE=0 #0=true +# +# Default is DUTY_CYCLE=0 to disable this feature. +DUTY_CYCLE=${DUTY_CYCLE:-0} + +EMERGENCY_ACTION=${EMERGENCY_ACTION:-900} +REBOOT_ENABLE=${REBOOT_ENABLE:-1} #0=true +USB_RESET_ENABLE=${USB_RESET_ENABLE:-1} #0=true + +function check_duty_cycle { + if [ -e /tmp/pump_loop_success ]; then + DIFF_SECONDS=$(expr $(date +%s) - $(stat -c %Y /tmp/pump_loop_success)) + + if ([ $USB_RESET_ENABLE ] || [ $REBOOT_ENABLE ]) && [ "$DIFF_SECONDS" -gt "$EMERGENCY_ACTION" ]; then + if [ $USB_RESET_ENABLE ]; then + USB_RESET_DIFF=$EMERGENCY_ACTION + if [ -e /tmp/usp_power_cycled ]; then + USB_RESET_DIFF=$(expr $(date +%s) - $(stat -c %Y /tmp/usp_power_cycled)) + fi + + if [ "$USB_RESET_DIFF" -gt "$EMERGENCY_ACTION" ]; then + # file is old --> power-cycling is long time ago (most probably not this round) --> power-cycling + echo -n "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> trying to reset USB... " + /usr/local/bin/oref0-reset-usb 2>&3 >&4 + touch /tmp/usp_power_cycled + echo " done. --> start new cycle." + return 0 #return to loop routine + fi + fi + # if usb reset doesn't help or is not enabled --> reboot system + if [ $REBOOT_ENABLE ]; then + echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> rebooting." + sudo shutdown -r now + exit 0 + fi + elif [ "$DIFF_SECONDS" -gt "$DUTY_CYCLE" ]; then + echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> start new cycle." + return 0 + else + echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> stop now." + exit 0 + fi + else + echo "/tmp/pump_loop_success does not exist; create it to start the loop duty cycle." + # if pump_loop_success does not exist, use the system uptime + touch -d "$(cat /proc/uptime | awk '{print $1}') seconds ago" /tmp/pump_loop_success + return 0 + fi +} + function overtemp { # check for CPU temperature above 85°C @@ -264,7 +338,7 @@ function smb_verify_status { false fi \ && if grep -q 12 monitor/status.json; then - echo -n "x12 model detected." + echo -n "x12 model detected." true fi } @@ -407,7 +481,7 @@ function preflight { # reset radio, init world wide pump (if applicable), mmtune, and wait_for_silence 60 if no signal function mmtune { if grep "carelink" pump.ini 2>&1 >/dev/null; then - echo "using carelink; skipping mmtune" + echo "using carelink; skipping mmtune" return fi @@ -458,7 +532,7 @@ function any_pump_comms { # listen for $1 seconds of silence (no other rigs talking to pump) before continuing function wait_for_silence { if grep "carelink" pump.ini 2>&1 >/dev/null; then - echo "using carelink; not waiting for silence" + echo "using carelink; not waiting for silence" return fi if [ -z $1 ]; then From 29c3bc5712cff7cae9063844b446e25143454dab Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Sat, 2 Jun 2018 12:31:25 -0700 Subject: [PATCH 12/23] update xDrip+ enableSMB warnings (#1017) * Update index.js Fix to warning message indicating Xdrip+ version is handling noisy data appropriately. * clarify From ab9cc74efecd9ec32b7e311c4d9eb4e81b972eff Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 2 Jun 2018 12:39:07 -0700 Subject: [PATCH 13/23] remove trailing spaces --- bin/oref0-pump-loop.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/oref0-pump-loop.sh b/bin/oref0-pump-loop.sh index ed3a4b937..a1f932beb 100755 --- a/bin/oref0-pump-loop.sh +++ b/bin/oref0-pump-loop.sh @@ -122,7 +122,7 @@ function fail { # If no loop has completed in that time, it performs the enabled actions. # !Note to enable a emergency action use 0 to enable and 1 to disable # -# The intention is two fold: +# The intention is two fold: # First the battery consumption is reduced (Pump and Pi) if the loop runs less often. # This is most dramatic for Enlite CGM, where wait_for_bg can't be used. # Secondly, if Carelink USB is used with Enlite, and wait_for_silence can't be used, this @@ -130,8 +130,8 @@ function fail { # # Use DUTY_CYCLE=0 (default) if you don't want to limit the loop # -# Suggestion for Carelink USB users are -# DUTY_CYCLE=120 +# Suggestion for Carelink USB users are +# DUTY_CYCLE=120 # EMERGENCY_ACTION=900 # REBOOT_ENABLE=0 #0=true # USB_RESET_ENABLE=0 #0=true @@ -143,17 +143,17 @@ EMERGENCY_ACTION=${EMERGENCY_ACTION:-900} REBOOT_ENABLE=${REBOOT_ENABLE:-1} #0=true USB_RESET_ENABLE=${USB_RESET_ENABLE:-1} #0=true -function check_duty_cycle { +function check_duty_cycle { if [ -e /tmp/pump_loop_success ]; then DIFF_SECONDS=$(expr $(date +%s) - $(stat -c %Y /tmp/pump_loop_success)) - if ([ $USB_RESET_ENABLE ] || [ $REBOOT_ENABLE ]) && [ "$DIFF_SECONDS" -gt "$EMERGENCY_ACTION" ]; then + if ([ $USB_RESET_ENABLE ] || [ $REBOOT_ENABLE ]) && [ "$DIFF_SECONDS" -gt "$EMERGENCY_ACTION" ]; then if [ $USB_RESET_ENABLE ]; then USB_RESET_DIFF=$EMERGENCY_ACTION - if [ -e /tmp/usp_power_cycled ]; then + if [ -e /tmp/usp_power_cycled ]; then USB_RESET_DIFF=$(expr $(date +%s) - $(stat -c %Y /tmp/usp_power_cycled)) fi - + if [ "$USB_RESET_DIFF" -gt "$EMERGENCY_ACTION" ]; then # file is old --> power-cycling is long time ago (most probably not this round) --> power-cycling echo -n "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> trying to reset USB... " @@ -167,9 +167,9 @@ function check_duty_cycle { if [ $REBOOT_ENABLE ]; then echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> rebooting." sudo shutdown -r now - exit 0 + exit 0 fi - elif [ "$DIFF_SECONDS" -gt "$DUTY_CYCLE" ]; then + elif [ "$DIFF_SECONDS" -gt "$DUTY_CYCLE" ]; then echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> start new cycle." return 0 else @@ -647,7 +647,7 @@ function get_settings { # On the x12 pumps, these 'reports' are simulated by static json files created during the oref0-setup.sh run. NON_X12_ITEMS="settings/bg_targets.json" else - # On all other supported pumps, these reports work. + # On all other supported pumps, these reports work. NON_X12_ITEMS="settings/bg_targets_raw.json settings/bg_targets.json settings/basal_profile.json settings/settings.json" fi retry_return timerun openaps report invoke settings/model.json settings/insulin_sensitivities_raw.json settings/insulin_sensitivities.json settings/carb_ratios.json $NON_X12_ITEMS 2>&3 >&4 | tail -1 || return 1 From 8e0afae7cce5bf27724172308bd10de9bdef88e9 Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 2 Jun 2018 12:40:55 -0700 Subject: [PATCH 14/23] remove trailing spaces --- bin/oref0-set-device-clocks.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/oref0-set-device-clocks.sh b/bin/oref0-set-device-clocks.sh index b635ba070..ebf444c2f 100755 --- a/bin/oref0-set-device-clocks.sh +++ b/bin/oref0-set-device-clocks.sh @@ -47,9 +47,8 @@ if checkNTP; then sudo ntpdate -s -b time.nist.gov echo Setting pump time to $(date) openaps use $PUMP set_clock --to now 2>&1 >/dev/null | tail -1 - # xdripaps CGM does not have a clock to set, so don't try. - if [ ! -f xdrip.ini ] - then + # xdripaps CGM does not have a clock to set, so don't try. + if [ ! -f xdrip.ini ]; then echo Setting CGM time to $(date) openaps use $CGM UpdateTime --to now 2>&1 >/dev/null | tail -1 fi From 158a8488a03b7879f2b529d2082bd3ec4fccb80e Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 2 Jun 2018 12:41:26 -0700 Subject: [PATCH 15/23] remove trailing spaces --- bin/oref0-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 76df68c68..51f1f4d95 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -854,7 +854,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then echo -n "Cloning subg_rfspy: " (cd $HOME/src && git clone https://github.com/ps2/subg_rfspy) || die "Couldn't clone oref0" fi - fi + fi fi # Medtronic CGM @@ -997,7 +997,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then echo "export API_SECRET" >> $HOME/.bash_profile echo - + #Check to see if Explorer HAT is present, and install all necessary stuff if grep -qa "Explorer HAT" /proc/device-tree/hat/product 2>/dev/null ; then echo "Looks like you're using an Explorer HAT!" @@ -1015,7 +1015,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then cp $HOME/src/openaps-menu/openaps-menu.service /etc/systemd/system/ && systemctl enable openaps-menu cd $HOME/myopenaps && openaps alias remove battery-status; openaps alias add battery-status '! bash -c "sudo ~/src/openaps-menu/scripts/getvoltage.sh > monitor/edison-battery.json"' fi - + if [[ "$ttyport" =~ "spi" ]]; then echo Resetting spi_serial reset_spi_serial.py From 58a972c4d02cdb0f1697674e4a87d9ebddad10eb Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 2 Jun 2018 12:45:18 -0700 Subject: [PATCH 16/23] Revert "Removing old to-do that's been taken care of" This reverts commit f92a01ead0e5186270920b27d61d2282d178569c. Conflicts: bin/oref0-setup.sh --- bin/oref0-setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 51f1f4d95..1e6451e85 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -854,6 +854,10 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then echo -n "Cloning subg_rfspy: " (cd $HOME/src && git clone https://github.com/ps2/subg_rfspy) || die "Couldn't clone oref0" fi + + # Hack to check if radio_locale has been set in pump.ini. + # It will remove empty line at the end of pump.ini and then append radio_locale if it's not there yet + grep -q radio_locale pump.ini || echo "$(< pump.ini)" > pump.ini ; echo "radio_locale=$radio_locale" >> pump.ini fi fi From da5a4bcacd82ae0e2aeabc95a672444fdfa51d8c Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 2 Jun 2018 13:37:30 -0700 Subject: [PATCH 17/23] only check_duty_cycle if "$DUTY_CYCLE" -gt "0" --- bin/oref0-pump-loop.sh | 64 ++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/bin/oref0-pump-loop.sh b/bin/oref0-pump-loop.sh index a1f932beb..6d2cd06bd 100755 --- a/bin/oref0-pump-loop.sh +++ b/bin/oref0-pump-loop.sh @@ -144,43 +144,45 @@ REBOOT_ENABLE=${REBOOT_ENABLE:-1} #0=true USB_RESET_ENABLE=${USB_RESET_ENABLE:-1} #0=true function check_duty_cycle { - if [ -e /tmp/pump_loop_success ]; then - DIFF_SECONDS=$(expr $(date +%s) - $(stat -c %Y /tmp/pump_loop_success)) - - if ([ $USB_RESET_ENABLE ] || [ $REBOOT_ENABLE ]) && [ "$DIFF_SECONDS" -gt "$EMERGENCY_ACTION" ]; then - if [ $USB_RESET_ENABLE ]; then - USB_RESET_DIFF=$EMERGENCY_ACTION - if [ -e /tmp/usp_power_cycled ]; then - USB_RESET_DIFF=$(expr $(date +%s) - $(stat -c %Y /tmp/usp_power_cycled)) - fi + if [ "$DUTY_CYCLE" -gt "0" ]; then + if [ -e /tmp/pump_loop_success ]; then + DIFF_SECONDS=$(expr $(date +%s) - $(stat -c %Y /tmp/pump_loop_success)) + + if ([ $USB_RESET_ENABLE ] || [ $REBOOT_ENABLE ]) && [ "$DIFF_SECONDS" -gt "$EMERGENCY_ACTION" ]; then + if [ $USB_RESET_ENABLE ]; then + USB_RESET_DIFF=$EMERGENCY_ACTION + if [ -e /tmp/usp_power_cycled ]; then + USB_RESET_DIFF=$(expr $(date +%s) - $(stat -c %Y /tmp/usp_power_cycled)) + fi - if [ "$USB_RESET_DIFF" -gt "$EMERGENCY_ACTION" ]; then - # file is old --> power-cycling is long time ago (most probably not this round) --> power-cycling - echo -n "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> trying to reset USB... " - /usr/local/bin/oref0-reset-usb 2>&3 >&4 - touch /tmp/usp_power_cycled - echo " done. --> start new cycle." - return 0 #return to loop routine + if [ "$USB_RESET_DIFF" -gt "$EMERGENCY_ACTION" ]; then + # file is old --> power-cycling is long time ago (most probably not this round) --> power-cycling + echo -n "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> trying to reset USB... " + /usr/local/bin/oref0-reset-usb 2>&3 >&4 + touch /tmp/usp_power_cycled + echo " done. --> start new cycle." + return 0 #return to loop routine + fi fi - fi - # if usb reset doesn't help or is not enabled --> reboot system - if [ $REBOOT_ENABLE ]; then - echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> rebooting." - sudo shutdown -r now + # if usb reset doesn't help or is not enabled --> reboot system + if [ $REBOOT_ENABLE ]; then + echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> rebooting." + sudo shutdown -r now + exit 0 + fi + elif [ "$DIFF_SECONDS" -gt "$DUTY_CYCLE" ]; then + echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> start new cycle." + return 0 + else + echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> stop now." exit 0 fi - elif [ "$DIFF_SECONDS" -gt "$DUTY_CYCLE" ]; then - echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> start new cycle." - return 0 else - echo "$DIFF_SECONDS (of $DUTY_CYCLE) since last run --> stop now." - exit 0 + echo "/tmp/pump_loop_success does not exist; create it to start the loop duty cycle." + # if pump_loop_success does not exist, use the system uptime + touch -d "$(cat /proc/uptime | awk '{print $1}') seconds ago" /tmp/pump_loop_success + return 0 fi - else - echo "/tmp/pump_loop_success does not exist; create it to start the loop duty cycle." - # if pump_loop_success does not exist, use the system uptime - touch -d "$(cat /proc/uptime | awk '{print $1}') seconds ago" /tmp/pump_loop_success - return 0 fi } From 4b2fab9436514993d1a9ff96269f9aa531149d4b Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 3 Jun 2018 19:23:15 -0700 Subject: [PATCH 18/23] xdrip.ini always exists: check for xdrip/ dir instead --- bin/oref0-set-device-clocks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/oref0-set-device-clocks.sh b/bin/oref0-set-device-clocks.sh index ebf444c2f..278074101 100755 --- a/bin/oref0-set-device-clocks.sh +++ b/bin/oref0-set-device-clocks.sh @@ -48,7 +48,7 @@ if checkNTP; then echo Setting pump time to $(date) openaps use $PUMP set_clock --to now 2>&1 >/dev/null | tail -1 # xdripaps CGM does not have a clock to set, so don't try. - if [ ! -f xdrip.ini ]; then + if [ ! -d xdrip ]; then echo Setting CGM time to $(date) openaps use $CGM UpdateTime --to now 2>&1 >/dev/null | tail -1 fi From 473641075f01d6ddbbb0cc60d25372b578e85acf Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Sun, 20 May 2018 13:43:20 -0400 Subject: [PATCH 19/23] Install MRAA on all kernel versions if it is needed. (#1015) --- bin/oref0-setup.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/oref0-setup.sh b/bin/oref0-setup.sh index 1e6451e85..5f214e903 100755 --- a/bin/oref0-setup.sh +++ b/bin/oref0-setup.sh @@ -775,16 +775,16 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ "$ttyport" =~ "spi" ]]; then echo Checking kernel for spi_serial installation if ! python -c "import spi_serial" 2>/dev/null; then - if uname -r 2>&1 | egrep "^4.1[0-9]"; then # kernel >= 4.10+, use pietergit version of spi_serial (does not use mraa) - echo Installing spi_serial && sudo pip install --upgrade git+https://github.com/pietergit/spi_serial.git || die "Couldn't install pietergit/spi_serial" - else # kernel < 4.10, use scottleibrand version of spi_serial (requires mraa) + #if uname -r 2>&1 | egrep "^4.1[0-9]"; then # kernel >= 4.10+, use pietergit version of spi_serial (does not use mraa) + # echo Installing spi_serial && sudo pip install --upgrade git+https://github.com/pietergit/spi_serial.git || die "Couldn't install pietergit/spi_serial" + #else # kernel < 4.10, use scottleibrand version of spi_serial (requires mraa) if [[ "$ttyport" =~ "spidev0.0" ]]; then echo Installing spi_serial && sudo pip install --upgrade git+https://github.com/scottleibrand/spi_serial.git@explorer-hat || die "Couldn't install scottleibrand/spi_serial for explorer-hat" sed -i.bak -e "s/#dtparam=spi=on/dtparam=spi=on/" /boot/config.txt else echo Installing spi_serial && sudo pip install --upgrade git+https://github.com/scottleibrand/spi_serial.git || die "Couldn't install scottleibrand/spi_serial" fi - fi + #fi #echo Installing spi_serial && sudo pip install --upgrade git+https://github.com/EnhancedRadioDevices/spi_serial || die "Couldn't install spi_serial" fi @@ -798,9 +798,9 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then openaps alias add mmtune "! bash -c \"oref0_init_pump_comms.py --ww_ti_usb_reset=yes -v; find monitor/ -size +5c | grep -q mmtune && cp monitor/mmtune.json mmtune_old.json; echo {} > monitor/mmtune.json; echo -n \"mmtune: \" && openaps report invoke monitor/mmtune.json; grep -v setFreq monitor/mmtune.json | grep -A2 $(cat monitor/mmtune.json | jq -r .setFreq) | while read line; do echo -n \"$line \"; done\"" fi echo Checking kernel for mraa installation - if uname -r 2>&1 | egrep "^4.1[0-9]"; then # don't install mraa on 4.10+ kernels - echo "Skipping mraa install for kernel 4.10+" - else # check if mraa is installed + #if uname -r 2>&1 | egrep "^4.1[0-9]"; then # don't install mraa on 4.10+ kernels + # echo "Skipping mraa install for kernel 4.10+" + #else # check if mraa is installed if ! ldconfig -p | grep -q mraa; then # if not installed, install it echo Installing swig etc. sudo apt-get install -y libpcre3-dev git cmake python-dev swig || die "Could not install swig etc." @@ -821,7 +821,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then make && sudo make install && echo && touch /tmp/reboot-required && echo mraa installed. Please reboot before using. && echo ) || die "Could not compile mraa" sudo bash -c "grep -q i386-linux-gnu /etc/ld.so.conf || echo /usr/local/lib/i386-linux-gnu/ >> /etc/ld.so.conf && ldconfig" || die "Could not update /etc/ld.so.conf" fi - fi + #fi fi echo Checking openaps dev installation From e30a7eb4f36c3ad003353f84f8737bb8791421f1 Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 7 Jun 2018 09:03:17 -0700 Subject: [PATCH 20/23] 0.6.2-dev --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e1925285a..2269ca8b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oref0", - "version": "0.6.1", + "version": "0.6.2-dev", "description": "openaps oref0 reference implementation of the reference design", "scripts": { "test": "make test", From f933a822f6a7406dc94c7e543eb1995287aa06d2 Mon Sep 17 00:00:00 2001 From: Dana Lewis Date: Sun, 10 Jun 2018 18:23:33 -0700 Subject: [PATCH 21/23] Adding links to documentation, and creating drop-down for readability --- README.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b9f45a41d..8ede8f1db 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,21 @@ # oref0 -Javascript plugins for openaps +Algorithm for OpenAPS implementations. To get started with OpenAPS, see the [OpenAPS documentation](http://openaps.readthedocs.org/en/latest/) -Master code coverage: [![Coverage Status](https://coveralls.io/repos/github/openaps/oref0/badge.svg?branch=master)](https://coveralls.io/github/openaps/oref0?branch=master) - -Dev code coverage: [![Coverage Status](https://coveralls.io/repos/github/openaps/oref0/badge.svg?branch=dev)](https://coveralls.io/github/openaps/oref0?branch=dev) - -## Installing +## Installing oref0 Install tools globally: `npm run global-install` -## Usage +## Usage of oref0 ### `oref0` -The open reference implementation of the reference design. + +
+ The open reference implementation of the reference design. (click to expand for more usage details) +
+ ``` Usage: oref0 @@ -85,9 +85,6 @@ These can be defined in crontab, or in a simple file, eg API_SECRET="..." NIGHTSCOUT_HOST=localhost:1337 ns-upload-entries ``` -## Contributing - -See the [CONTRIBUTING document](CONTRIBUTING.md) ### Get the source ``` @@ -115,6 +112,11 @@ git push origin -u wip/my-enhancement-fix-or-proposal ``` Then target our `dev` branch for a pull request/peer review. +
+ +## Contributing + +See the [CONTRIBUTING document](CONTRIBUTING.md). PRs welcome! ## openaps @@ -140,4 +142,6 @@ mindset to learn what are essentially "building blocks" to implement an OpenAPS instance. This is not a "set and forget" system; it requires diligent and consistent testing and monitoring to ensure each piece of the system is monitoring, predicting, and performing as desired. The -performance and quality of your system lies solely with you. +performance and quality of your system lies solely with you. + +Read the [OpenAPS documentation](http://openaps.readthedocs.io/en/latest/) for more details. From 26df3af5d3c9dea53d9b3ef7078d3d1932aca51b Mon Sep 17 00:00:00 2001 From: Dana Lewis Date: Sun, 10 Jun 2018 18:26:04 -0700 Subject: [PATCH 22/23] Fixing link to modern docs, and recommending others ways to contribute --- CONTRIBUTING.md | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ad2bacf1..d4706a25e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,26 +30,10 @@ performance and quality of your system lies solely with you. Additionally, this community of contributors believes in "paying it forward", and individuals who are implementing these tools are asked to contribute by asking questions, helping improve documentation, and -contribute in other ways. +contribute in other ways. We always need testers for various pieces of works-in-progress; please do ask if you would like to help but aren't sure where to get started. Please submit issues and pull requests so that all users can share -knowledge. If you're unfamiliar with GitHub and/or coding, [check out these other ways to get involved with OpenAPS.](https://openaps.gitbooks.io/building-an-open-artificial-pancreas-system/content/docs/Overview/contribute.html) - -For hacking on openaps, here are some tips to help your patches reach -more people more quickly. The `master` branch is special, it should -be "production" ready code, tested and verified, and should match the -contents available in pypi. Basically that means the `master` branch -is never touched directly, but rather we use a variety of other -branches to do things, and then merge the work into the `master` -branch. Sometimes this is called -[git flow](http://nvie.com/posts/a-successful-git-branching-model/). -Here's few guidelines that might help: - - * target a `dev` branch for pull requests. The latest updated - branch, especially any recently updated branch with `dev` in the - name. - * Avoid editing `master` branch. - * test changes +knowledge. If you're unfamiliar with GitHub and/or coding, [check out these other ways to get involved with OpenAPS.](http://openaps.readthedocs.io/en/latest/docs/Give%20Back-Pay%20It%20Forward/contribute.html) See [OpenAPS.org](http://OpenAPS.org/) for background on the OpenAPS movement and project. From 7a473f7d81240515e96b69c61223f8c8f8a7fc21 Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Wed, 13 Jun 2018 00:01:39 -0400 Subject: [PATCH 23/23] 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. --- bin/openaps-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/openaps-install.sh b/bin/openaps-install.sh index df66b9874..e813fc731 100755 --- a/bin/openaps-install.sh +++ b/bin/openaps-install.sh @@ -28,7 +28,7 @@ dpkg-reconfigure tzdata #dpkg -P nodejs nodejs-dev # TODO: remove the `-o Acquire::ForceIPv4=true` once Debian's mirrors work reliably over IPv6 apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true -y dist-upgrade && apt-get -o Acquire::ForceIPv4=true -y autoremove -apt-get -o Acquire::ForceIPv4=true install -y sudo strace tcpdump screen acpid vim python-pip locate ntpdate +apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true install -y sudo strace tcpdump screen acpid vim python-pip locate ntpdate #check if edison user exists before trying to add it to groups if getent passwd edison > /dev/null; then