#!/bin/sh

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

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

./simple_adec_bind_ao -r 8000 -t g711a -i audio/ledTestStart.pcm

if [ "$LEDMODE" = "1" ];then
	io -4 0xFF538008 0x00070000
    io -4 0xFF530008 0x01000100
    io -4 0xFF530000 0x01000100
	sleep 2
	io -4 0xFF530000 0x01000000
	sleep 2
	XmGpio sethigh 1 9
	sleep 2
	XmGpio setlow 1 9
fi

if [ "$LEDMODE" = "2" ];then
	XmGpio sethigh 1 9
	sleep 2
	XmGpio setlow 1 9
	sleep 2
	XmGpio sethigh 0 0
	sleep 2
	XmGpio setlow 0 0
fi

./simple_adec_bind_ao -r 8000 -t g711a -i audio/ledTestEnd.pcm
