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

Delete Future Data for better recovery of Time on System during No network power on for edison #413

Merged
merged 6 commits into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bin/oref0-delete-future-entries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Since the Edison does not have an internal clock
# after a reboot if you do not have the correct time your date will be older than
# the time on the CGM data in the monitor folder.
# Currently all the checks for time in the system is looking at data being older than current
# time
# This will delete all the data in the
# monitor directory. Allowing oref0 to gather all of the data again in pump-loop

NEWTIME=$(date -d `(jq .[1].display_time monitor/glucose.json; echo ) | sed 's/"//g'` +%s)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we need to install jq by default before this will work for everyone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll go make that PR in docs

TIME=$(date --date '5 minutes' +%s)

echo $NEWTIME
echo $TIME

if [ $NEWTIME -gt $TIME ]; then
echo CGM Time is newer than Edison Time$'\n'Deleting All Monitor Files
sudo rm -rf monitor/*
elif [ $NEWTIME -lt $TIME ]; then
echo "No Newer CGM Data found"
fi
1 change: 1 addition & 0 deletions bin/oref0-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
if [[ ! -z "$BT_PEB" || ! -z "$BT_MAC" ]]; then
(crontab -l; crontab -l | grep -q "oref0-bluetoothup" || echo '* * * * * ps aux | grep -v grep | grep -q "oref0-bluetoothup" || oref0-bluetoothup >> /var/log/openaps/network.log' ) | crontab -
fi
(crontab -l; crontab -l | grep -q "cd $directory && oref0-delete-future-entries" || echo "@reboot cd $directory && oref0-delete-future-entries") | crontab -
crontab -l | tee $HOME/crontab.txt
fi

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
"oref0-autotune-export-to-xlsx": "./bin/oref0-autotune-export-to-xlsx.py",
"oref0-autotune-prep": "./bin/oref0-autotune-prep.js",
"oref0-autotune-recommends-report": "./bin/oref0-autotune-recommends-report.sh",
"oref0-bluetoothup": "./bin/oref0-bluetoothup.sh",
"oref0-calculate-iob": "./bin/oref0-calculate-iob.js",
"oref0-copy-fresher": "./bin/oref0-copy-fresher",
"oref0-crun": "./bin/oref0-conditional-run.sh",
"oref0-delete-future-entries": "./bin/oref0-delete-future-entries.sh",
"oref0-detect-sensitivity": "./bin/oref0-detect-sensitivity.js",
"oref0-determine-basal": "./bin/oref0-determine-basal.js",
"oref0-dexusb-cgm-loop": "./bin/oref0-dexusb-cgm-loop.py",
Expand Down Expand Up @@ -72,7 +74,6 @@
"oref0-truncate-git-history": "bin/oref0-truncate-git-history.sh",
"send-tempbasal-Azure": "./bin/send-tempbasal-Azure.js",
"peb-urchin-status": "./bin/peb-urchin-status.sh",
"oref0-bluetoothup": "./bin/oref0-bluetoothup.sh",
"wifi": "./bin/oref0-tail-wifi.sh"
},
"homepage": "https://github.com/openaps/oref0",
Expand Down