-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from xdrip-js/auto-restart-2nd-cal
Two automatic calibrations (native and LSR) on g5 restarts
- Loading branch information
Showing
4 changed files
with
130 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
#!/bin/bash | ||
# always do 120 minutes ago for sensor stop message. Allows time travel for subsequent start. | ||
minutesago=120 | ||
MESSAGE="${HOME}/myopenaps/monitor/xdripjs/cgm-stop.json" | ||
|
||
if [ -n "$minutesago" ]; then | ||
epochdate=$(date +'%s%3N' -d "$minutesago minutes ago") | ||
common_funcs="/root/src/Logger/bin/logger-common-funcs.sh" | ||
if [ ! -e $common_funcs ]; then | ||
echo "ERROR: Failed to run logger-common-funcs.sh. Is Logger correctly installed?" | ||
exit 1 | ||
fi | ||
source $common_funcs | ||
|
||
# Except for new firmware transmitters, always do 120 minutes ago | ||
# for sensor stop message. Allows time travel for subsequent start. | ||
|
||
version=$(txVersion) | ||
if [ $(newFirmware $version) == "true" ]; then | ||
# time travel not allowed for new firmware tx versions | ||
minutesago=0 | ||
else | ||
epochdate=$(date +'%s%3N') | ||
# always time travel in this case | ||
minutesago=120 | ||
fi | ||
|
||
MESSAGE="${HOME}/myopenaps/monitor/xdripjs/cgm-stop.json" | ||
|
||
epochdate=$(date +'%s%3N' -d "$minutesago minutes ago") | ||
|
||
echo "[{\"date\":\"${epochdate}\",\"type\":\"StopSensor\"}]" > $MESSAGE | ||
cat $MESSAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/echo This file should be source'd from another script, not run directly: | ||
# | ||
# Common functions for shell script components of Logger. | ||
|
||
LDIR="${HOME}/myopenaps/monitor/xdripjs" | ||
|
||
function newFirmware() | ||
{ | ||
local version=$1 | ||
case $version in | ||
1.6.5.27 | 2.*) | ||
echo true | ||
;; | ||
*) | ||
echo false | ||
;; | ||
esac | ||
} | ||
|
||
function txVersion() | ||
{ | ||
local tx_version="" | ||
if [ -e "${LDIR}/tx-version.json" ]; then | ||
tx_version=$(cat ${LDIR}/tx-version.json | jq -M '.firmwareVersion') | ||
tx_version="${tx_version%\"}" | ||
tx_version="${tx_version#\"}" | ||
fi | ||
|
||
echo $tx_version | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,34 @@ | ||
#!/bin/bash | ||
|
||
common_funcs="/root/src/Logger/bin/logger-common-funcs.sh" | ||
if [ ! -e $common_funcs ]; then | ||
echo "ERROR: Failed to run logger-common-funcs.sh. Is Logger correctly installed?" | ||
exit 1 | ||
fi | ||
source $common_funcs | ||
|
||
#KNOWN_G5_FIRMWARES = ("1.0.0.13", "1.0.0.17", "1.0.4.10", "1.0.4.12"); | ||
#KNOWN_G6_FIRMWARES = ("1.6.5.23", "1.6.5.25", "1.6.5.27"); | ||
#KNOWN_G6_REV2_FIRMWARES = ("2.18.2.67", "2.18.2.88"); | ||
#KNOWN_TIME_TRAVEL_TESTED = ("1.6.5.25"); | ||
|
||
function newFirmware() | ||
function testVersion() | ||
{ | ||
local version=$1 | ||
case $version in | ||
1.6.5.27 | 2.*) | ||
echo true | ||
;; | ||
*) | ||
echo false | ||
;; | ||
esac | ||
if [ "$(newFirmware $version)" == "true" ]; then | ||
echo "'$version' is new firmware" | ||
else | ||
echo "'$version' is not new firmware" | ||
fi | ||
} | ||
|
||
version="1.6.5.27" | ||
if [ "$(newFirmware $version)" == "true" ]; then | ||
echo "$version is new firmware" | ||
else | ||
echo "$version is not new firmware" | ||
fi | ||
|
||
|
||
version="2.18.2.88" | ||
if [ "$(newFirmware $version)" == "true" ]; then | ||
echo "$version is new firmware" | ||
else | ||
echo "$version is not new firmware" | ||
fi | ||
|
||
version="1.0.0.17" | ||
if [ "$(newFirmware $version)" == "true" ]; then | ||
echo "$version is new firmware" | ||
else | ||
echo "$version is not new firmware" | ||
fi | ||
|
||
version="" | ||
if [ "$(newFirmware $version)" == "true" ]; then | ||
echo "$version is new firmware" | ||
else | ||
echo "$version is not new firmware" | ||
fi | ||
|
||
version="1.6.5.25" | ||
if [ "$(newFirmware $version)" == "true" ]; then | ||
echo "$version is new firmware" | ||
else | ||
echo "$version is not new firmware" | ||
fi | ||
echo "real version test" | ||
version=$(txVersion)&& testVersion | ||
echo "fake version tests" | ||
version="1.6.5.27" && testVersion | ||
version="2.18.2.67" && testVersion | ||
version="2.18.2.88" && testVersion | ||
version="1.0.0.17" && testVersion | ||
version="" && testVersion | ||
version="1.6.5.25" && testVersion | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters