Skip to content

Commit

Permalink
Merge branch 'dev' into clockset
Browse files Browse the repository at this point in the history
Conflicts:
	bin/oref0-set-device-clocks.sh
  • Loading branch information
scottleibrand committed Oct 4, 2016
2 parents bcb0ca7 + 7965786 commit acd8f26
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bin/oref0-set-device-clocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ checkNTP() { ntp-wait -n 1 -v || ( sudo /etc/init.d/ntp restart && ntp-wait -n 1

if checkNTP; then
sudo ntpdate -s -b time.nist.gov
echo Setting pump and CGM time to `date`
echo Setting pump and CGM time to $(date)
openaps use $PUMP set_clock --to now
openaps use $CGM UpdateTime --to now
fi
10 changes: 5 additions & 5 deletions bin/oref0-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ else
(cd ~/src && git clone -b dev git://github.com/openaps/oref0.git) || die "Couldn't clone oref0 dev"
fi
echo Checking oref0 installation
( grep -q oref0_glucose_since `which nightscout` && oref0-get-profile --exportDefaults 2>/dev/null >/dev/null ) || (echo Installing latest oref0 dev && cd $HOME/src/oref0/ && npm run global-install)
( grep -q oref0_glucose_since $(which nightscout) && oref0-get-profile --exportDefaults 2>/dev/null >/dev/null ) || (echo Installing latest oref0 dev && cd $HOME/src/oref0/ && npm run global-install)

echo Checking mmeowlink installation
if openaps vendor add --path . mmeowlink.vendors.mmeowlink 2>&1 | grep "No module"; then
Expand All @@ -206,7 +206,7 @@ if openaps vendor add --path . mmeowlink.vendors.mmeowlink 2>&1 | grep "No modul
echo Installing latest mmeowlink dev && cd $HOME/src/mmeowlink/ && sudo pip install -e . || die "Couldn't install mmeowlink"
fi

cd $directory
cd $directory || die "Can't cd $directory"
if [[ "$max_iob" -eq 0 ]]; then
oref0-get-profile --exportDefaults > preferences.json || die "Could not run oref0-get-profile"
else
Expand Down Expand Up @@ -323,8 +323,8 @@ if [[ -z "$ttyport" ]]; then
openaps alias add mmtune 'report invoke monitor/temp_basal.json'
else
openaps device add pump mmeowlink subg_rfspy $ttyport $serial || die "Can't add pump"
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"'
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"'
fi

# Medtronic CGM
Expand Down Expand Up @@ -371,7 +371,7 @@ read -p "Schedule openaps in cron? y/[N] " -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
# add crontab entries
(crontab -l; crontab -l | grep -q "$NIGHTSCOUT_HOST" || echo NIGHTSCOUT_HOST=$NIGHTSCOUT_HOST) | crontab -
(crontab -l; crontab -l | grep -q "API_SECRET=" || echo API_SECRET=`nightscout hash-api-secret $API_SECRET`) | crontab -
(crontab -l; crontab -l | grep -q "API_SECRET=" || echo API_SECRET=$(nightscout hash-api-secret $API_SECRET)) | crontab -
(crontab -l; crontab -l | grep -q "PATH=" || echo "PATH=$PATH" ) | crontab -
if [[ ${CGM,,} =~ "shareble" ]]; then
# cross-platform hack to make sure experimental bluetoothd is running for openxshareble
Expand Down
12 changes: 6 additions & 6 deletions headless/headless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Interface='wlan0'
HostAPDIP='10.29.29.1'
echo "-----------------------------------"
echo "Checking for DHCP leases"
clients=`cat /var/lib/misc/dnsmasq.leases | wc -l`
clients=$(cat /var/lib/misc/dnsmasq.leases | wc -l)
echo "$clients DHCP clients found"
if [[ $clients -eq 0 ]]; then
hostapd=`pidof hostapd`
hostapd=$(pidof hostapd)
if [[ ! -z $hostapd ]]; then
echo "Activating client config"
cp /etc/network/interfaces.client /etc/network/interfaces
Expand All @@ -40,7 +40,7 @@ if [[ $clients -eq 0 ]]; then
/etc/init.d/networking stop
echo "Starting networking"
/etc/init.d/networking start
wpasup=`pidof wpa_supplicant`
wpasup=$(pidof wpa_supplicant)
if [[ -z $wpasup ]]; then
echo "Attempting to start wpa_supplicant"
sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
Expand All @@ -49,13 +49,13 @@ if [[ $clients -eq 0 ]]; then
/sbin/dhclient wlan0
else
echo "Checking connectivity of $Interface"
NetworkUp=`/sbin/ifconfig $Interface`
IP=`echo "$NetworkUp" | grep inet | wc -l`
NetworkUp=$(/sbin/ifconfig $Interface)
IP=$(echo "$NetworkUp" | grep inet | wc -l)
if [[ $IP -eq 0 || $NetworkUp =~ $HostAPDIP ]]; then
#if [[ $IP -eq 0 ]]; then
#echo "Connection is down"

hostapd=`pidof hostapd`
hostapd=$(pidof hostapd)
if [[ -z $hostapd ]]; then
# If there are any more actions required when the interface goes down, add them here
echo "Killing wpa_supplicant"
Expand Down
12 changes: 6 additions & 6 deletions lib/oref0-setup/alias.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "alias",
"name": "mmtune",
"mmtune": {
"command": "! bash -c \"reset_spi_serial.py 2>/dev/null; echo {} > monitor/mmtune.json; echo -n \\\"mmtune: \\\" && openaps report invoke monitor/mmtune.json 2>/dev/null >/dev/null; grep -v setFreq monitor/mmtune.json | grep -A2 `json -a setFreq -f monitor/mmtune.json` | while read line; do echo -n \\\"$line \\\"; done\""
"command": "! bash -c \"reset_spi_serial.py 2>/dev/null; echo {} > monitor/mmtune.json; echo -n \\\"mmtune: \\\" && openaps report invoke monitor/mmtune.json 2>/dev/null >/dev/null; grep -v setFreq monitor/mmtune.json | grep -A2 $(json -a setFreq -f monitor/mmtune.json) | while read line; do echo -n \\\"$line \\\"; done\""
}
},
{
Expand Down Expand Up @@ -51,7 +51,7 @@
{
"type": "alias",
"ns-temptargets": {
"command": "! bash -c \"curl -m 30 -s \\\"$NIGHTSCOUT_HOST/api/v1/treatments.json?find\\[created_at\\]\\[\\$gte\\]=`date -d \\\"6 hours ago\\\" -Iminutes`&find\\[eventType\\]\\[\\$regex\\]=Target\\\" > settings/temptargets.json; openaps report invoke settings/profile.json 2>/dev/null >/dev/null; exit 0 \""
"command": "! bash -c \"curl -m 30 -s \\\"$NIGHTSCOUT_HOST/api/v1/treatments.json?find\\[created_at\\]\\[\\$gte\\]=$(date -d \\\"6 hours ago\\\" -Iminutes)&find\\[eventType\\]\\[\\$regex\\]=Target\\\" > settings/temptargets.json; openaps report invoke settings/profile.json 2>/dev/null >/dev/null; exit 0 \""
},
"name": "ns-temptargets"
},
Expand All @@ -78,7 +78,7 @@
},
{
"get-bg": {
"command": "! bash -c \"openaps monitor-cgm 2>/dev/null | tail -1 && grep -q glucose cgm/cgm-glucose.json && rsync -rtu cgm/cgm-glucose.json cgm/glucose.json; rsync -rtu cgm/glucose.json monitor/glucose.json\""
"command": "! bash -c \"openaps monitor-cgm 2>/dev/null | tail -1 && grep -q glucose cgm/cgm-glucose.json && cp -pu cgm/cgm-glucose.json cgm/glucose.json; cp -pu cgm/glucose.json monitor/glucose.json\""
},
"type": "alias",
"name": "get-bg"
Expand All @@ -87,7 +87,7 @@
"type": "alias",
"name": "get-ns-bg",
"get-ns-bg": {
"command": "! bash -c \"openaps get-ns-glucose && cat cgm/ns-glucose.json | json -c \\\"minAgo=(new Date()-new Date(this.dateString))/60/1000; return minAgo < 10 && minAgo > -5 && this.glucose > 30\\\" | grep -q glucose && rsync -rtu cgm/ns-glucose.json cgm/glucose.json; rsync -rtu cgm/glucose.json monitor/glucose.json\""
"command": "! bash -c \"openaps get-ns-glucose && cat cgm/ns-glucose.json | json -c \\\"minAgo=(new Date()-new Date(this.dateString))/60/1000; return minAgo < 10 && minAgo > -5 && this.glucose > 30\\\" | grep -q glucose && cp -pu cgm/ns-glucose.json cgm/glucose.json; cp -pu cgm/glucose.json monitor/glucose.json\""
}
},
{
Expand Down Expand Up @@ -171,12 +171,12 @@
"type": "alias",
"name": "ns-loop",
"ns-loop": {
"command": "! bash -c \"echo Starting ns-loop at `date`: && openaps get-ns-bg; openaps ns-temptargets && echo -n Refreshed temptargets && openaps ns-meal-carbs && echo \\\" and meal-carbs\\\" && openaps upload\""
"command": "! bash -c \"echo Starting ns-loop at $(date): && openaps get-ns-bg; openaps ns-temptargets && echo -n Refreshed temptargets && openaps ns-meal-carbs && echo \\\" and meal-carbs\\\" && openaps upload\""
}
},
{
"pump-loop": {
"command": "! bash -c \"sleep $[ ( $RANDOM / 2048 ) ]s; until(echo Starting pump-loop at `date`: && openaps wait-for-silence && openaps refresh-old-pumphistory && openaps refresh-old-pumphistory-24h && openaps refresh-old-profile && openaps refresh-temp-and-enact && openaps refresh-pumphistory-and-enact && openaps refresh-profile && openaps refresh-pumphistory-24h && echo Completed pump-loop at `date` && echo); do echo Error, retrying && [[ $RANDOM > 28000 ]] && openaps wait-for-long-silence && openaps mmtune; sleep 5; done\""
"command": "! bash -c \"sleep $[ ( $RANDOM / 2048 ) ]s; until(echo Starting pump-loop at $(date): && openaps wait-for-silence && openaps refresh-old-pumphistory && openaps refresh-old-pumphistory-24h && openaps refresh-old-profile && openaps refresh-temp-and-enact && openaps refresh-pumphistory-and-enact && openaps refresh-profile && openaps refresh-pumphistory-24h && echo Completed pump-loop at $(date) && echo); do echo Error, retrying && [[ $RANDOM > 28000 ]] && openaps wait-for-long-silence && openaps mmtune; sleep 5; done\""
},
"type": "alias",
"name": "pump-loop"
Expand Down
2 changes: 1 addition & 1 deletion lib/oref0-setup/mdt-cgm.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
{
"pump-loop": {
"command": "! bash -c \"sleep $[ ( $RANDOM / 2048 ) ]s; until(echo Starting pump-loop at `date`: && openaps wait-for-silence && openaps get-bg && openaps refresh-old-pumphistory && openaps refresh-old-pumphistory-24h && openaps refresh-old-profile && openaps refresh-temp-and-enact && openaps refresh-pumphistory-and-enact && openaps refresh-profile && openaps refresh-pumphistory-24h && echo Completed pump-loop at `date` && echo); do echo Error, retrying && [[ $RANDOM > 30000 ]] && openaps wait-for-long-silence && openaps mmtune; sleep 5; done\""
"command": "! bash -c \"sleep $[ ( $RANDOM / 2048 ) ]s; until(echo Starting pump-loop at $(date): && openaps wait-for-silence && openaps get-bg && openaps refresh-old-pumphistory && openaps refresh-old-pumphistory-24h && openaps refresh-old-profile && openaps refresh-temp-and-enact && openaps refresh-pumphistory-and-enact && openaps refresh-profile && openaps refresh-pumphistory-24h && echo Completed pump-loop at $(date) && echo); do echo Error, retrying && [[ $RANDOM > 30000 ]] && openaps wait-for-long-silence && openaps mmtune; sleep 5; done\""
},
"type": "alias",
"name": "pump-loop"
Expand Down
16 changes: 8 additions & 8 deletions lib/templates/refresh-loops.json
Original file line number Diff line number Diff line change
Expand Up @@ -498,19 +498,19 @@
"type": "alias",
"name": "mmtune",
"mmtune": {
"command": "! bash -c \"echo -n \\\"mmtune: \\\" && openaps report invoke monitor/mmtune.json 2>/dev/null >/dev/null; grep -v setFreq monitor/mmtune.json | grep -A2 `json -a setFreq -f monitor/mmtune.json` | while read line; do echo -n \\\"$line \\\"; done\""
"command": "! bash -c \"echo -n \\\"mmtune: \\\" && openaps report invoke monitor/mmtune.json 2>/dev/null >/dev/null; grep -v setFreq monitor/mmtune.json | grep -A2 $(json -a setFreq -f monitor/mmtune.json) | while read line; do echo -n \\\"$line \\\"; done\""
}
},
{
"type": "alias",
"name": "wait-for-silence",
"wait-for-silence": {
"command": "! bash -c \"echo -n \\\"Listening: \\\"; for i in `seq 1 100`; do echo -n .; ~/src/mmeowlink/bin/mmeowlink-any-pump-comms.py --port /dev/mmeowlink --wait-for 30 2>/dev/null | egrep -v subg | egrep No && break; done\""
"command": "! bash -c \"echo -n \\\"Listening: \\\"; for i in $(seq 1 100); do echo -n .; ~/src/mmeowlink/bin/mmeowlink-any-pump-comms.py --port /dev/mmeowlink --wait-for 30 2>/dev/null | egrep -v subg | egrep No && break; done\""
}
},
{
"wait-for-long-silence": {
"command": "! bash -c \"echo -n \\\"Listening: \\\"; for i in `seq 1 100`; do echo -n .; ~/src/mmeowlink/bin/mmeowlink-any-pump-comms.py --port /dev/mmeowlink --wait-for 45 2>/dev/null | egrep -v subg | egrep No && break; done\""
"command": "! bash -c \"echo -n \\\"Listening: \\\"; for i in $(seq 1 100); do echo -n .; ~/src/mmeowlink/bin/mmeowlink-any-pump-comms.py --port /dev/mmeowlink --wait-for 45 2>/dev/null | egrep -v subg | egrep No && break; done\""
},
"type": "alias",
"name": "wait-for-long-silence"
Expand Down Expand Up @@ -539,7 +539,7 @@
{
"type": "alias",
"ns-temptargets": {
"command": "! bash -c \"curl -m 30 -s \\\"$NIGHTSCOUT_HOST/api/v1/treatments.json?find\\[created_at\\]\\[\\$gte\\]=`date -d \\\"6 hours ago\\\" -Iminutes`&find\\[eventType\\]\\[\\$regex\\]=Target\\\" > settings/temptargets.json; openaps report invoke settings/profile.json 2>/dev/null >/dev/null; exit 0 \""
"command": "! bash -c \"curl -m 30 -s \\\"$NIGHTSCOUT_HOST/api/v1/treatments.json?find\\[created_at\\]\\[\\$gte\\]=$(date -d \\\"6 hours ago\\\" -Iminutes)&find\\[eventType\\]\\[\\$regex\\]=Target\\\" > settings/temptargets.json; openaps report invoke settings/profile.json 2>/dev/null >/dev/null; exit 0 \""
},
"name": "ns-temptargets"
},
Expand All @@ -566,7 +566,7 @@
},
{
"get-bg": {
"command": "! bash -c \"openaps monitor-cgm 2>/dev/null | tail -1 && grep -q glucose cgm/cgm-glucose.json && rsync -rtu cgm/cgm-glucose.json cgm/glucose.json; rsync -rtu cgm/glucose.json monitor/glucose.json\""
"command": "! bash -c \"openaps monitor-cgm 2>/dev/null | tail -1 && grep -q glucose cgm/cgm-glucose.json && cp -pu cgm/cgm-glucose.json cgm/glucose.json; cp -pu cgm/glucose.json monitor/glucose.json\""
},
"type": "alias",
"name": "get-bg"
Expand All @@ -575,7 +575,7 @@
"type": "alias",
"name": "get-ns-bg",
"get-ns-bg": {
"command": "! bash -c \"openaps get-ns-glucose && cat cgm/ns-glucose.json | json -c \\\"minAgo=(new Date()-new Date(this.dateString))/60/1000; return minAgo < 10 && minAgo > -5 && this.glucose > 30\\\" | grep -q glucose && rsync -rtu cgm/ns-glucose.json cgm/glucose.json; rsync -rtu cgm/glucose.json monitor/glucose.json\""
"command": "! bash -c \"openaps get-ns-glucose && cat cgm/ns-glucose.json | json -c \\\"minAgo=(new Date()-new Date(this.dateString))/60/1000; return minAgo < 10 && minAgo > -5 && this.glucose > 30\\\" | grep -q glucose && cp -pu cgm/ns-glucose.json cgm/glucose.json; cp -pu cgm/glucose.json monitor/glucose.json\""
}
},
{
Expand Down Expand Up @@ -659,12 +659,12 @@
"type": "alias",
"name": "ns-loop",
"ns-loop": {
"command": "! bash -c \"echo Starting ns-loop at `date`: && openaps get-ns-bg; openaps autosens; openaps ns-temptargets && echo -n Refreshed temptargets && openaps ns-meal-carbs && echo \\\" and meal-carbs\\\" && openaps upload\""
"command": "! bash -c \"echo Starting ns-loop at $(date): && openaps get-ns-bg; openaps autosens; openaps ns-temptargets && echo -n Refreshed temptargets && openaps ns-meal-carbs && echo \\\" and meal-carbs\\\" && openaps upload\""
}
},
{
"pump-loop": {
"command": "! bash -c \"sleep $[ ( $RANDOM / 2048 ) ]s; until(echo Starting pump-loop at `date`: && openaps wait-for-silence && openaps refresh-old-pumphistory && openaps refresh-old-pumphistory-24h && openaps refresh-old-profile && openaps refresh-temp-and-enact && openaps refresh-pumphistory-and-enact && openaps refresh-profile && openaps refresh-pumphistory-24h && echo Completed pump-loop at `date` && echo); do echo Error, retrying && [[ $RANDOM > 30000 ]] && openaps wait-for-long-silence && openaps mmtune; sleep 5; done\""
"command": "! bash -c \"sleep $[ ( $RANDOM / 2048 ) ]s; until(echo Starting pump-loop at $(date): && openaps wait-for-silence && openaps refresh-old-pumphistory && openaps refresh-old-pumphistory-24h && openaps refresh-old-profile && openaps refresh-temp-and-enact && openaps refresh-pumphistory-and-enact && openaps refresh-profile && openaps refresh-pumphistory-24h && echo Completed pump-loop at $(date) && echo); do echo Error, retrying && [[ $RANDOM > 30000 ]] && openaps wait-for-long-silence && openaps mmtune; sleep 5; done\""
},
"type": "alias",
"name": "pump-loop"
Expand Down
2 changes: 1 addition & 1 deletion logrotate.openaps
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
/var/log/openaps/loop.log {
/var/log/openaps/*.log {
rotate 30
daily
size 10M
Expand Down

0 comments on commit acd8f26

Please sign in to comment.