Skip to content
Closed
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
21 changes: 21 additions & 0 deletions bin/oref0-cron-post-reboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ if [[ "${CGM,,}" =~ "xdrip" ]]; then
python "$XDRIP_PATH/xDripAPS.py" &
fi

# Get time from pump for offline looping in case a rig was down for a while
# At some point the rig will come online again and calibrates the local clock
# and the clock of the pump
export MEDTRONIC_PUMP_ID=`get_pref_string .pump_serial | tr -cd 0-9`
export MEDTRONIC_FREQUENCY=`cat monitor/medtronic_frequency.ini`

sudo wpa_cli -i wlan0 scan
sleep 60 # wait for wifi to connect

if ! ifconfig | grep wlan0 -A 1 | grep -q inet ; then
echo "$(date) -- Not online, getting clock from pump with $MEDTRONIC_PUMP_ID and $MEDTRONIC_FREQUENCY " >> /var/log/openaps/clock.log
date -s $(mdt clock | sed 's/"//g')
while [ $? -ne 0 ]; do
echo "$(date) -- FAILED. Trying again" >> /var/log/openaps/clock.log
sleep 15
date -s $(mdt clock | sed 's/"//g')
done
echo "$(date) -- SUCCESS" >> /var/log/openaps/clock.log
fi
# END CLOCK

oref0-delete-future-entries &

(
Expand Down