#!/bin/sh
echo "aa: vk2fqzl active antenna test begins"
amixer set 'Master' 31 >/dev/null

nm-down
aplay /usr/share/olpc-radio-testing/sounds/sine-42.wav 2>/dev/null >/dev/null
echo -n "aa: at synchronisation point ALPHA, standing by ..."
read ok

ADDR=`ifconfig eth1 | grep HWaddr | awk '{print $5}'`

case "$ADDR" in
    "00:50:43:28:0B:07")
        IP=10.1.6.66
        SN=0666
	;;
    "00:50:43:28:0B:0D")
	IP=10.1.6.52
	SN=0652
	;;
    *)
	echo 'hardware address not in test set'
	exit 1
	;;
esac

iwconfig eth1 essid test mode ad-hoc channel 6
ifconfig eth1 ${IP} netmask 255.255.255.0

echo "aa: this node IP is ${IP} for serial number ${SN}"
aplay /usr/share/olpc-radio-testing/sounds/sine-44.wav 2>/dev/null >/dev/null

amixer set 'Master' 15 >/dev/null
echo "aa: volume is set to LOW (use key above equals for high volume)"
echo " "
