FLASH_FILE=$REPO/loaders/telebt-v$VERSION-altos-flash-*.bin
ALTOS_FILE=$REPO/telebt-v$VERSION-*.elf
-$DFU_UTIL -a 0 -s 0x08000000:leave -D $FLASH_FILE || exit 1
+$DFU_UTIL -a 0 -s 0x08000000:leave -D $FLASH_FILE
sleep 2
;;
esac
+CALFILE=cal-$SERIAL.txt
+
echo 'E 0' > $dev
-SERIAL=$SERIAL ./cal-freq $dev
+../ao-tools/ao-cal-freq/ao-cal-freq --nosave --output=$CALFILE --tty=$dev
+
+# echo 'E 1' > $dev
-echo 'E 1' > $dev
+CAL_VALUE=`cat $CALFILE`
+echo $SERIAL","$CAL_VALUE >> cal_values
+echo "Reflashing with calibration: $CAL_VALUE"
+$USBLOAD --cal=$CAL_VALUE --tty=$dev $ALTOS_FILE || exit 1
echo -n "checking BlueTooth functionality... "
btdev=`hcitool scan | awk -F \- '/TeleBT/ { print $2 }'`
fi
echo -n "checking BTLE functionality... "
-btdev=`sudo timeout -s SIGINT 5s hcitool lescan | awk -F \- '/TeleBT/ { print $2 }'`
+btdev=`sudo timeout -s SIGINT 5s hcitool lescan | awk -F \- '/TeleBT/ { print $2 }' | head -n 1`
if [ "$btdev" = "$SERIAL" ]; then
echo "working!"
else