#!/bin/sh
#
#description: insert/remove bluetooth module
#processname: btmgr
#

RETVAL=0

start(){
        ENABLE_BT_RADIO=`/usr/bin/ICTApplication/ICTCliGateLite --call SettingsManager:getSettingValue --args BTRadioEnable`
        if [ "$ENABLE_BT_RADIO" = "false" ]
        then
                echo "ENABLE_BT_RADIO is false, btkernel btusb btuart btprot btdrvif btserial will not be loaded" 
                exit $RETVAL
        fi
	modprobe btkernel 
	modprobe btusb
	modprobe btuart 
	modprobe btprot 
	modprobe btdrvif 
	modprobe btserial

	ln -sf btchar0 /dev/btchar
	ln -s /dev/ttyBt2 /dev/modem
}
stop() {
	modprobe -r btserial 
	modprobe -r btdrvif
	modprobe -r btprot 
	modprobe -r btuart 
	modprobe -r btusb 
	modprobe -r btkernel
} 
# See how we were called
case "$1" in
     start)
         start
         ;;
     stop)
         stop
         ;;
     restart)
         stop
         start
         ;;
     *)
         echo $"Usage: $0 {start|stop|restart}"
         ;;
esac
exit $RETVAL 

