summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-10-02 17:27:31 -0700
committerKeith Packard <keithp@keithp.com>2018-10-02 17:27:31 -0700
commit3094d1f0ebd734f62d35e5e989d9a2368b713d29 (patch)
treebcd24793b4540211198350d9a2cee6009a543590
parentc2c7873695ee2dc1b6fd153b67accad9693937aa (diff)
ao-bringup: Add 'fix-telebt' to reflash TeleBT v4.0 with correct rf cal
Fetches RF calibration value from the net and applies that when reflashing. Signed-off-by: Keith Packard <keithp@keithp.com>
-rwxr-xr-xao-bringup/fix-telebt52
1 files changed, 52 insertions, 0 deletions
diff --git a/ao-bringup/fix-telebt b/ao-bringup/fix-telebt
new file mode 100755
index 00000000..35933e9f
--- /dev/null
+++ b/ao-bringup/fix-telebt
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+VERSION=4.0
+REPO=~/altusmetrumllc/Binaries
+PRODUCT=TeleBT
+
+ALTOS_FILE=$REPO/telebt-v$VERSION-*.elf
+
+if [ -x /usr/bin/ao-usbload ]; then
+ USBLOAD=/usr/bin/ao-usbload
+else
+ echo "Can't find ao-usbload! Aborting."
+ exit 1
+fi
+
+dev_serial=`ao-list | awk '/'"$PRODUCT"'-v'"$VERSION"'/ { printf("%s %s\n", $3, $2); exit(0); }'`
+dev=`echo $dev_serial | awk '{print $1;}'`
+serial=`echo $dev_serial | awk '{print $2;}'`
+
+case "$dev" in
+/dev/tty*)
+ ;;
+*)
+ echo 'No '"$PRODUCT"'-v'"$VERSION"' found'
+ exit 1
+ ;;
+esac
+
+rfcal=`wget -O - -q 'http://altusmetrum.org/cgi-bin/unitinfo.cgi?sn='$serial | jq '.unitinfo.rfcal | tonumber'`
+
+case $? in
+0)
+ ;;
+*)
+ echo "Fetch rfcal for $serial failed"
+ exit 1
+ ;;
+esac
+
+case "$rfcal" in
+[0-9]*)
+ ;;
+*)
+ echo "Serial $serial: invalid rfcal $rfcal"
+ ;;
+esac
+
+echo "$PRODUCT"'-v'"$VERSION $serial $dev rfcal $rfcal"
+
+$USBLOAD --cal=$rfcal --tty=$dev $ALTOS_FILE || exit 1
+
+echo "$PRODUCT"'-v'"$VERSION $serial $dev is ready to ship"