Release ConBTGPS


Oct 6, 2008
Because I was bored by manual connection of BT GPS, I've put together a script which automatize this process.

Big thanks to sebt3 for AWK parsing of rfcomm.conf file!

What ConBTGPS expects?

1) you've installed gpsd

2) your BT GPS is added in /etc/bluetooth/rfcomm.conf

3) your BT GPS is turned on

Check the wiki for details how to install gpsd and add your BT GPS.

What ConBTGPS does?

It checks if your BT is on - if not, it starts it up, if your BT GPS is correctly added in /etc/bluetooth/rfcomm.conf and if gpsd is running.

If these conditions are met, it tries to connect with your BT GPS and checks if there is any communication.

What ConBTGPS doesn't?

It doesn't check the GPS signal or satelite visibility. It's also incapable of making a breakfast for you :)

Before I upload it into repos, I ask those of you who are using BT GPS with either TangoGPS or modRana (or any other mapping app) for testing. Let me know about any issues you find.

If anybody wants to amend the script for USB GPS, feel free to do it.

And here's the script. I was resurrecting my shell scripting skills after long years so don't be surprised if you find any glitches or weird constructions in it.


# Delete control file from previous sessions

rm .btcommtemp

# Inform user 

zenity --info --text="ConBTGPS\n\nTurn on your BT GPS first."

# Check if bluetooth is on.

if [ ! -f $HOME/.op_btenabled ];


          echo BT is OFF, starting it.

	  # Using OP script to turn BT on.



          echo BT was already ON.


# We don't want to let the program write its configuration, savestates etc. to the NAND.

#So we need to export our HOME environment variable first.

export HOME=/mnt/utmp/conbtgps/

# stop gpsd first

sudo /etc/init.d/gpsd stop

# release all possibly connected devices

echo Trying to release all previously connected BT devices. 

sudo rfcomm release all

# Check if rfcomm.conf exists

if [ -f /etc/bluetooth/rfcomm.conf ]; 


		echo /etc/bluetooth/rfcomm.conf exists, OK.

		MYBTGPSMAC=`awk 'BEGIN{r="";f=0}END{if(f==1)print r}/^rfcomm/&&(f==0||r==""){f=0;r=""}/device.*;/&&r==""{r=substr($2,1,length($2)-1)}/comment/&&/GPS/{f=1}'  < /etc/bluetooth/rfcomm.conf`

		# Check if MYBTGPSMAC is not empty

		if [ ! "$MYBTGPSMAC" ];


		        echo No appropriate MAC address found in /etc/bluetooth/rfcomm.conf!

		        zenity --error --text="ConBTGPS\n\nNo appropriate MAC address found in /etc/bluetooth/rfcomm.conf!"

		        exit 1


				# Validate format of MAC address

				if [ `echo $MYBTGPSMAC | sed -n "/^\([0-9A-Z][0-9A-Z]:\)\{5\}[0-9A-Z][0-9A-Z]$/p"` ];


						# Connect to BT GPS device

						GPSDEVICE=`awk 'BEGIN{r=""}/^rfcomm/{r=$1}/comment/&&/GPS/{print r;exit}' < /etc/bluetooth/rfcomm.conf`

						sudo rfcomm bind /dev/$GPSDEVICE $MYBTGPSMAC

						echo Connecting to $MYBTGPSMAC

						# Start gpsd

						gpsd /dev/$GPSDEVICE;

						echo Starting gpsd ...

						# gpsd check


						if ps ax | grep -v grep | grep $SERVICE > /dev/null


								echo "$SERVICE started successfully."

								head /dev/$GPSDEVICE > .btcommtemp

								notify-send -u normal "ConBTGPS" "Waiting for BT GPS response."

								sleep 6


								if [ -s $BTCOMMTEMP ];


										notify-send -u normal "ConBTGPS" "BT GPS is connected."

										#Tidy up

										rm .btcommtemp


										zenity --error --text="ConBTGPS\n\nThere is no communication running on $GPSDEVICE\nMake sure your BT GPS is on."



								echo "$SERVICE is not running"

								zenity --error --text="ConBTGPS\n\ngpsd is not running or installed. GPS positioning will not be available."



				        	# Wrong address

						echo MAC address has wrong format.

						zenity --error --text="ConBTGPS\n\nBT GPS MAC address in /etc/bluetooth/rfcomm.conf has wrong format."




		echo "/etc/bluetooth/rfcomm.conf does not exist!"

		zenity --error --text="ConBTGPS\n\n/etc/bluetooth/rfcomm.conf doesn't exist."

		exit 1


Edit: 2011-06-15

To download the latest version of ConBTGPS, go to



  • conbtgps.pnd
    85.2 KB · Views: 316
Last edited by a moderator:
One small thing - could I ask that instead of

export HOME=/mnt/utmp/conbtgps/

you have something like:


export HOME=$pwd

I realise that 'mnt/utmp' is where always mounts stuff, but I've started to worry that if anybody ever wants to change it in the future, they won't be able to because loads of pnds will break.

Thank you.
Looks reasonably to me.

First I have to test it as I don't know if it could affect creation of app folder in pandora/appdata.

Or is the app data folder derived from app name in PXML?
It's no problem mentioning it in the wiki. But I would put it BELOW the initial manual setup process.

First the user must:

1) pair the BT GPS

2) connect it following the steps from wiki - most importantly to insert the BT GPS MAC address into rfcomm.conf

3) then the ConBTGPS can be used (no need to fiddle with command line anymore)

It is working for me with Nokia LD-3W BT GPS but I see that nobody downloaded the app so far so I just hope that it will work on others OPs.

I'll also put ConBTGPS into repos after I write down more complete step-by-step setup procedure (basicaly copying stuff from wiki and one GPS thread on GP32X forums).


OK, I've updated the wiki page.

Edit2: @freamon: Your way of exporting $HOME is already implemented in version which will be in repo.
Last edited by a moderator:
Sorry for grave digging, but there is really no sense starting a new thread and there is nothing newer that I can find specific to this app. This is great to start the GPS, but what do you need to do in order to shut everything down when you are done?
Watchout! Zombie comes out! :-D

I think the only thing that is left by this script is gpsd. So something like:

sudo killall gpsd

followed by:

sudo rfcomm release all

shoud do the job.

If I get bored I might update the script to offer the termination of the gps daemon in case there is active connection.
What are the current instructions for installing GPSD? It is not in the repository.
I just followed the link that was posted earlier for the feeds and copied the link to the current versions of each of the apps. As someone mentioned, there was some frustration with satisfying the dependencies, but I worked through them one at a time. A pnd would be a great alternative, but the files are there and they install and work fine.