Do you need to track your device?
Until now, you couldn't get external access to the GPS inside your iPhone, but now with GPS 2 IP you can stream the information in realtime to solve your requirements.
There are three methods to get the GPS data with GPS 2 IP:
Connect to the iPhone with a socket
The iPhone becomes a GPS server, and to get the information, you just connect to your iPhone.
Methods for connection include gpsd, telnet, netcat, iTerm, or many other terminal programs.
Send TCP packets to your own server
Setup your server to receive TCP packets, and send the raw data to it.
This works even if your cellular provider has put your device behind a NAT, without a public IP.
This can be as easy as
$ nc -l 11123 | tee ~/gpsOutput.txt if using netcat.
New for version 2 - Send UDP packets to your own server
Setup your server to receive UDP packets, and send the raw data to it.
This works exactly the same as the TCP version, but supports older systems that require UDP.
There are three formats that can be selected:
Different NMEA messages can be selected for transmission,
and more will be added in the coming months.
Currently, four NMEA formats can be selected:
- $GPGGA - Global Positioning System Fix Data
- $GPRMC - Recommended minimum specific GPS/Transit data
- $HCHDG - Magnetic heading and variation
- $GPGLL - Geographic position, Lat/Long & time
Since each NMEA message is entirely self contained, all NMEA messages can be output at the same time, or separately.
Also a non-standard NMEA message $PASHR - Roll and pitch
A GPX file can be produced, which can then be used
in Google Earth, OziExplorer,
FlightTrack, and dozens of other GPS applications and services.
If an application reads in a GPS file, it'll probably be fine with a GPX file.
The output file has been validated, and is ready to import into your favorite software.
How to use GPS 2 IP
By default, the GGA and RMC NMEA message types are transmitted when GPS 2 IP is enabled with the switch in the top right of the main
The type of messages sent can be configured on the settings page, by tapping the settings button in the navigation bar. On the same screen, the accuracy of GPS updates can be changed. This update setting ranges from sending one update for every 3km travelled, through to near-constant updates. This last setting does require significant energy to operate, so plugging in your iPhone is recommended to prevent excessive battery drain.
The maximum frequency of sending data can be changed by altering a slider in the settings, labelled "Time between sending Positions".
Connecting to GPS 2 IP with a socket
When GPS 2 IP is enabled, the IP address of the iPhone is displayed. A listening socket is opened on that address, ready for connection. Below are some examples of connecting to GPS 2 IP:
On a Mac:
Start a terminal session, and telnet to the address and the port shown.
This example shows NMEA message output:
... the GPX output:
..and KML output:
You can redirect the serial traffic with something like:
$ telnet 10.0.0.8 11123 | tee ~/gpsOutput.txt
$ telnet 10.0.0.8 11123 | tee /dev/ttyS0
socat can create a virtual serial port for you on your mac.
To pipe the tcp socket data from GPS 2 IP to a (new) virtual serial port, you can use something like:
socat GOPEN:/dev/ptype0,ignoreeof TCP:192.168.1.72:11123.
Then (if you're using OpenCPN), just set the NMEA data source type to "/dev/ttyp0" with a baud rate of 4800bps.
(Thanks for the help, John!)
On a PC:
For Console telnet,
op 10.0.0.8 11123 starts the connection.
For Realterm, in the "Port" tab, set the "Port" setting to the desired IP, such as
10.0.0.8:11123, and click "Change".
For Tera Term, at startup, in the TCP/IP selection panel, the "Host" address is the iPhone's IP address, the "TCP port#" is 11123, and the "Service" should be set to Telnet.
Using GPS 2 IP to push data to your server
If you set the Connection Method to TCP Push, then GPS 2 IP sends the navigation data to the URL specified on the main screen.
After entering the URL (including the port) in the format server_ip_address:server_port (such as 126.96.36.199:6690), GPS 2 IP will attempt to send the data to that address.
A simple way to listen for data is to open up a port on your router, and use a commandline utility such as netcat and do something like
$ nc -l 6690 | tee /dev/ttyS0 to send the data to a serial port in real time.
Ways to get your iPhone on a network
Wireless LAN - wifi
Probably the easiest way to connect to your iDevice is over a wireless LAN (wifi).
If your iDevice is on the same network as you are, it will be assigned an IP address similar to yours (perhaps 192.168.1.7, or similar).
Ad-hoc network - wifi
Another simple method is to set up an Ad-hoc network and connect your iDevice to it. Your device might end up with an IP of something like 169.254.52.233. (Steps mercilessly borrowed from digidna.net)
For Mac OS X
- Open the “Airport Menu” from the top right of your screen
- Click on “Create Network”
- Enter a name, and a password if you wish to. Leave the Channel Field as is
- Click OK
For Windows Vista
- Open the “Start menu” and click “Control Panel”
- Click “Network and Internet”
- Click “Network and Sharing Center”
- Click “Set up a connection or network” from the left side of the window
- Choose “Set up a wireless ad hoc (computer-to-computer) network.”
- Click Next
- Click Next
- Enter a name
- Set up a password for your network if you wish
- Click Next and Close
- Click Close
For Windows XP
- Open the “Start menu”, and click “My Network Places”
- Click “View network connections” from the left side of the window
- Find your wireless network connection, right click on it, and click Properties
- Click the Wireless Networks tab
- Click Advanced
- Select “Computer-to-computer (ad hoc) networks only” then click Close
- Click Add
- Give your network a name (this is what you will connect to later on your iPhone)
- Set up a password for your network if you wish. Uncheck the box next to “The key is provided for me automatically” if you want to enter a password. Select Disabled in the Data encryption drop down menu if you do not wish to have a password
- Click OK
- Click OK
Tethering with USB cable (Hotspot)
When your iDevice is connected to your mac with a USB cable, you should get an IP address like 172.20.10.1.
Cellular Data Connection - Edge/GPRS/3G/..
This is the method you use to connect to the internet when out of range of any wifi network - when you're in the car, for example.
Sometimes your cellular provider will not assign you a 'real' IP address (visible from outside their network), but an
address essentially on their LAN, behind their NAT system.
This means you cannot telnet to your iDevice.
You should ask them to assign you a publicly accessible IP address.
Using GPS 2 IP with gpsd
gspd is a daemon that receives data from a GPS receiver, and
provides the data back to multiple applications such as Kismet, or OpenCPN. If you have software that
interprets a gpsd connection, you can easily connect to GPS 2 IP.
The command-line options allow you to specify an TCP socket as the data source.
That's exactly what GPS 2 IP is!
About two pages down into the command-line options is:
TCP feedA URI with the prefix "tcp://", followed by a hostname, a colon, and a port number. The daemon will open a socket to the indicated address and port and read data packets from it, which will be interpreted as though they had been issued by a serial device.
So, startup gpsd with your iDevice IP address
gpsd tcp://192.168.1.70:11123, and you'll be receiving
the data very simply.
(Hint): gpsd can be quite easily installed on a mac with macports (with or without a GUI frontend).
port install gpsd should do it.
Using OpenCPN with GPS 2 IP
OpenCPN can read from gpsd, so using it with GPS 2 IP is easy:
- Start GPS 2 IP
- Start gpsd with the correct address (as above): gpsd tcp://192.168.1.70:11123
- Set OpenCPN to Network GPSD for the NMEA Data Source setting
- Set the GPS Data Source IP Address to whatever address gpsd is running on (probably your local computer IP)
You can alternatively read from a serial port, so connecting to GPS 2 IP
$ telnet 10.0.0.8 11123 | tee /dev/ttyS0 (on a Mac) will
connect to GPS 2 IP, and output the data to the serial port.
Ensure that the NMEA Data Source setting is configured correctly, and you will be able to read the data just fine.
Using MacENC with GPS 2 IP
- Launch GPS 2 IP on your iPhone
- Adjust desired NMEA messages for output - Set to "ON"
- Launch MacENC
- Select "TCP/IP" on the "GPS" menu
- Enter the IP Address shown in GPS 2 IP in the MacENC TCP/IP NMEA Data Client Host (i.e. 10.0.1.8)
- Enter the Port shown in GPS 2 IP in the MacENC TCP/IP NMEA Data Client Port (i.e. 11123)
- Select "Enable" in the MacENC TCP/IP NMEA Data Client
- If the connection is successful the circular indicator in MacENC TCP/IP NMEA Data Client will turn green AND the GPS 2 IP Connected clients will list your Macs IP address (i.e. 10.0.1.6)
- To see the lat/lon/sog/cog select "Connect" on the MacENC "GPS" menu
Provisos, caveats, etc..
The iPhone is a great, powerful platform to develop for, but Apple doesn't let us become the omnipotent developers we would prefer with phenominal cosmic power ("itty-bitty living space").
So, there are limitations to GPS 2 IP:
- We don't know the number of satellites tracked. This is fixed at 8 in this app
- Likewise, the Horizontal Dilution of Position is fixed to 0.9
- The Height of Geoid above WGS84A ellipsoid is fixed to 46.9
Sometimes (depending on your plan), your Cellular provider does not give you an IP accessible from
outside that network. Often your IP addess would be something like 10.*.*.*, if you are behind their NAT.
This means that you cannot telnet to your iDevice, and you will have to use another connection method, such as an ad-hoc network.
v1.0 - Initial version
- Added Greek localisation
- Added the GPX format
- Added the KML format
- Enabled connections to GPS 2 IP before GPS turned on
- Added ability to remove a client with a swipe
- Added Czech localisation
- Added German localisation
- Added French localisation
- Added Spanish localisation
- Added Swedish localisation
- Added Japanese localisation
- Added Korean localisation
- Added Italian localisation
- Added Polish localisation
- Added Icelandic localisation
- Added Russian localisation
- Fixed a crash on client disconnect bug
- Added Chinese (simplified) localisation
- Added ability to keep transmitting position while in Background Mode (when the app isn't running on the screen, or the iPhone is 'asleep'). This was due to a user request.
- Changed 'info' icon to Settings button for clarity (User request).
- Added Danish localisation
- Added NMEA $HCHDG message
- Added NMEA $GPGLL message.
- Added selectable order for IP interfaces
- Corrected NMEA time from local to UTC
- Fixed message format when COG or SOG not available or invalid
- Added Norwegian localisation (Thanks Karoline! :)
- Added TCP push mode (User request) (Huge thanks for testing, Mike! :)
- Added throttling to sending messages rate
- Fixed Bluetooth PAN network selection
- Added Croatian localisation
- Fixed Magnetic variation and heading orientation errors (Thanks, David :)
- Added Hungarian localisation (Thanks Gergely!)
- Made GPS2IP GRLevel2-compliant with extra data in $GPGGA message (Thanks David!)
- Added UDP push mode
- Added non-standard NMEA $PASHR message