#/bin/sh


device="/dev/ttyHS0"
baud=115200

Usage="Invalid command.!
Usage: 
1. do3 pow <> freq <>
2. do3 pow <>
3. do3 freq <>
4. do3
5. do3 stop
"

#do3 freq <n> pow <n> 
if [ $# -eq 4 ]; then
    if [[ "$1" != 'pow' ]] ; then
        echo $Usage
        exit
    fi
    if [[ "$3" != 'freq' ]] ; then
        echo $Usage
        exit
    fi
    /usr/bin/ble_app -t $device -b baud -p $2 -f $4
fi

#do3 pow <n>
#do3 freq <n>
if [ $# -eq 2 ]; then
    if [[ "$1" == 'pow' ]] ; then
        /usr/bin/ble_app -t $device -b baud -p $2
        exit
    fi
    if [[ "$1" == 'freq' ]] ; then
        /usr/bin/ble_app -t $device -b baud -f $2
        exit
    fi
    echo $Usage
fi

#default case: do3
if [ $# -eq 0 ]; then
    /usr/bin/ble_app -t $device -b baud -p 0 -f 2402 
    exit
fi

#do3 stop 
if [ $# -eq 1 ]; then
    if [[ "$1" == 'stop' ]]; then 
        /usr/bin/ble_app -t $device -b baud -s 1
        exit
    fi
    echo $Usage
fi

## end
