Bluetooth GPS Setup, how to check it works?

So I think i have gotten a bluetooth GPS to work with my pwnagotchi. Just need to know how I can validate this once I have captured a handshake.

To get this old bluetooth GPS to connect I first paired and trusted the GPS’ bluetooth MAC in bluetoothctl the same as I did my phone with bt-tether.

Next up I had to add a com port for it to speak to the system, for this I used rfcomm:

sudo rfcomm bind /dev/rfcomm1 <MAC>

I could then access this via screen:

screen /dev/rfcomm1

I enabled the GPS plugin and changed the com port to /dev/rfcomm1 in my config.yml. Now I just need to confirm that this has worked. Any pointers on how to do this?

1 Like

Hey- I followed your lead and did get it to work, but the process is a bit convoluted.

The first problem is that /dev/rfcomm1 dissapears (not sure if it is deleted or what) each time the pi turned off and needs to be manually created each boot.

the second is that i can only get /dev/rfcomm1 to be initialized and read if I “summon” it by opening a screen -screen /dev/rfcomm1 38400

…Meaning that the serial stream from rfcomm1 is only being seen while I have the screen open/connected to rfcomm1. Then the Pwnagotchi “sees” the gps data and displays the coordinates. If I close the connection to rfcomm1 or restart pwnagotchi (this doesnt remove the rfcomm1/bt device bind) the pwnagotchi is no longer getting gps data.

it seems that we need a way to both create/bind rfcomm1 and open/initialize it, as the pwnagotchi’s gps plugin doesnt seem to be demanding enough on its own. (Even when it is connecting and running logs still say “no GPS detected”, btw)
I would think that a simple script would do the trick, but that prob reveals how little i know.

Ok got it working. found the solution (and copied and pasted my reply from )here:
https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=125922&sid=aa467f9eaaf76422f48207d051b2b651&start=25

this is what i did to get rfcomm1 created on startup:

Edit the /etc/rc.local and add:

"rfcomm bind 0 XX:XX:XX:XX:XX:XX " before the “exit 0”

This works well, but something needs to “look” at the com port for serial to flow so I had to do this:

create new one service rfcomm

sudo nano /etc/systemd/system/rfcomm.service

and put this inside (note MAC address):

[Unit]
Description=RFCOMM service
After=bluetooth.service
Requires=bluetooth.service

[Service]
ExecStart=/usr/bin/rfcomm watch remote_device_MAC 1
Restart=on-failure
RestartSec=5s
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

save, exit and then enable the service with:

sudo systemctl enable rfcomm

bingo…it works. However… i have not been able to get it to reconnect if it goes out of range or the power on the gps is cut momentarily, without resarting the pwnagotchi. Perhaps tweaking the restart conditions would get it to reconnect? The post in the forum i linked mention changing /etc/systemd/system/dbus-org.bluez.service fixes the reconnect issue but that isnt a file that is on my pwnagotchi.

Also it may have broken shared internet with my phone… or i just have a bad connection in my apartment. (Its too cold to go outside and walk around to properly test) :confused:

Im not that fluent in python, but a bluetooth_serial plugin could be pretty handy to set this all up, not just for gps but other sensors, a remote serial console, etc

Thanks! It helped me. Tough I would suggest one change. Don’t assume it will be on channel 1. Took me a few shots because I didn’t get 1 was the channel he was using, mine was Chanel 8 because I was using my phone’s GPS. Found the command “sdptool browse local” very useful. for this, to work it needs to be paired and connected already. hope that hint helps someone down the road.

And yes the reconnect issue still needs a reboot. I have yet to solve that. I’m just happy I have bluetooth gps for the price of a cheap app

Oh and I found a missing step I forgot to include

rfcomm bind <hci device ex. hci0. XX:XX:XX:XX:XX:XX
hci device can be gotten with rdkill list
and the channel (Must be conncted)
sdptool browse XX:XX:XX:XX:XX:XX
You are looking for SSP Slave most likely