~/Blog

Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Forwarding Phone's GPS

Published on

Updated on

2 minute reading time

Warning: This post has not been modified for over 2 years. For technical posts, make sure that it is still relevant.

Sometimes I wish to open up Marble which an a mapping application and see my current location on the globe. My laptop, however, doesn’t have a GPS module in it. Though I realized that I carry around a device that does… My phone.

Tiago Shibata wrote a great Android application called GPSd Forwarder which allows you to forward the NMEA data from your phone’s GPS to another device over UDP. The user interface of the app is really simple and only requires you to put an ip address and a port of the device you want to stream the GPS data to.

For sake of example, let’s say we’re sending UDP packets to the ip address of 192.168.0.86 and a port of 29998.

As a good sanity check, let’s make sure that the computer is receiving those UDP packets.

nc -lu 29998

You should see a constant stream of output that looks similar to:

$GNGSA,A,2,324,,,,,,,,,,,,1.2,0.9,0.8,3*05

Then we need a piece of software that knows how to process this NMEA message. For that we use gpsd.

To install,

sudo apt install gpsd gpsd-clients

For the purposes of this demo, we’ll disable the automatic socket daemon and tell gpsd to listen on the udp port 29998.

sudo systemctl stop gpsd.socket
sudo gpsd -N udp://*:29998

To sanity check that gpsd is processing the data, you can make sure there’s output in gpsmon.

Finally to hook this into Marble, go to Settings -> Panel -> Location. Then in the location pane change the Position Tracking option to “gpsd”.

Reply via Email Buy me a Coffee
Was this useful? Feel free to share: Hacker News Reddit Twitter

Published a response to this? :