#!/bin/sh

PTT_RFKILL_SWITCH=y
PTT_BT_MODULES="rfcomm hci_usb hidp bnep l2cap sco btusb btrtl hci_uart btintel bluetooth"

PTT_CONFIGFILE=~/.config/ptt.d/pttbluetooth.conf
if [ ! -f $PTT_CONFIGFILE ]; then
	PTT_CONFIGFILE=/etc/ptt.d/pttbluetooth.conf
fi
if [ -f $PTT_CONFIGFILE ]; then
	. $PTT_CONFIGFILE
fi

# if no parameters, exec also init script
if [ "x$1" = "x" ]; then
	/etc/init.d/bluetooth stop
	sleep 1
fi
if [ "$PTT_RFKILL_SWITCH" = "y" ]; then
	PTT_ID=`rfkill list | grep hci0 | cut -f1 -d":"`
	rfkill block $PTT_ID
fi
rmmod $PTT_BT_MODULES 

