#!/bin/sh
#
# Start the bluetooth GPS receiver...
#

GPS_BTADDR="00:0E:6D:0A:D9:2E"
RFCOMM="/dev/rfcomm1"

start() {
 	echo "Starting bluetooth GPS receiver..."
	#hcitool scan
	hcitool cc $GPS_BTADDR
	hcitool con
	rfcomm bind $RFCOMM $GPS_BTADDR
	rfcomm show
	gpsd -p $RFCOMM -D 1
}	
stop() {
	echo -n "Stopping bluetooth GPS receiver..."
	killall gpsd
	rfcomm release $RFCOMM
	hcitool dc $GPS_BTADDR
}
restart() {
	stop
	sleep 2;
	start
}	

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart|reload)
  	restart
	;;
  *)
	echo $"Usage: $0 {start|stop|restart}"
	exit 1
esac

exit $?

