#!/bin/sh

script_path=`echo $0 | awk -F '/' '{for(i=2;i<NF;i++) printf"/"$i}'`

echo  $script_path >> test

STARTUPTYPE=`cat $script_path/wifiStartupType.ini | ./busybox grep "StartupType:" | ./busybox grep -v grep | sed 's/StartupType://g' | sed 's/\r//g' | sed 's/\n//g' | sed "s/$(echo -e '\015')//g"`
if [ $? != 0 ]; then
	echo "cann't found wifiStartupType in config file"
	exit -1
fi

echo STARTUPTYPE = $STARTUPTYPE >> test

if [ "$STARTUPTYPE" = "Station" ];then
	echo -e "StartupType:0" > /mnt/mtd/Log/WifiStartupType
	./simple_adec_bind_ao -r 8000 -t g711a -i audio/wifiStation.pcm
elif [ "$STARTUPTYPE" = "softAP" ];then
	echo -e "StartupType:1" > /mnt/mtd/Log/WifiStartupType
	./simple_adec_bind_ao -r 8000 -t g711a -i audio/wifisoftAP.pcm
elif [ "$STARTUPTYPE" = "Stationremain" ];then
	echo -e "StartupType:2" > /mnt/mtd/Log/WifiStartupType
	./simple_adec_bind_ao -r 8000 -t g711a -i audio/wifiStation.pcm
elif [ "$STARTUPTYPE" = "softAPremain" ];then
	echo -e "StartupType:3" > /mnt/mtd/Log/WifiStartupType
	./simple_adec_bind_ao -r 8000 -t g711a -i audio/wifisoftAP.pcm	
else
	./simple_adec_bind_ao -r 8000 -t g711a -i audio/wifiUnknown.pcm
fi
