#!/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
	./playOrRecord -p 0 audio/wifiStation.pcm
elif [ "$STARTUPTYPE" = "softAP" ];then
	echo -e "StartupType:1" > /mnt/mtd/Log/WifiStartupType
	./playOrRecord -p 0 audio/wifisoftAP.pcm
elif [ "$STARTUPTYPE" = "Stationremain" ];then
	echo -e "StartupType:2" > /mnt/mtd/Log/WifiStartupType
	./playOrRecord -p 0 audio/wifiStation.pcm
elif [ "$STARTUPTYPE" = "softAPremain" ];then
	echo -e "StartupType:3" > /mnt/mtd/Log/WifiStartupType
	./playOrRecord -p 0 audio/wifisoftAP.pcm	
else
	./playOrRecord -p 0 audio/wifiUnknown.pcm
fi
