This article describes how you can connect a phone through Bluetooth to a GPS receiver (for example Bluei) and how you can use the GPS data. This can be done using a mobile phone that supports the JSR 82 API, for example the Sony Ericsson K750 or K600 phones. NMEA (National Marine Electronics Association) is the standard protocol for GPS data and by parsing the data sent from the GPS receiver we can get information about our position, the current time, our current speed and so on. Before we can start to read data from the GPS device, we must first establish a Bluetooth connection. To find all available devices a DiscoveryAgent and a DiscoveryListener is used and from the devices that are found, we can get the connection URL. | ![]() |
String url = "btspp://000A5600F776:1;authenticate=false;encrypt=false;master=true"
StreamConnection conn = (StreamConnection)Connector.open(url);
InputStream is = conn.openInputStream();
When the connection is made we can start retrieving the GPS data.
do{
i = is.read();
c = (char)i;
}while(i != -1);Here is an example string that is sent from the GPS and it starts with "$GP"
GGA,123519,4807.038,N,01131.324,E,1,08,0.9,545.4,M,46.9,M, , *42
123519 Fix taken at 12:35:19 UTC
4807.038,N Latitude 48 deg 07.038' N
01131.324,E Longitude 11 deg 31.324' E
1 Fix quality: 0 = invalid
1 = GPS fix
2 = DGPS fix
08 Number of satellites being tracked
0.9 Horizontal dilution of position
545.4,M Altitude, Metres, above mean sea level
46.9,M Height of geoid (mean sea level) above WGS84
ellipsoid
(empty field) time in seconds since last DGPS update
(empty field) DGPS station ID number
The URL is a string with the following form:
{scheme}:{target}{params}
- {scheme} is the "btspp" protocol
- {target} is the network address starting with "//"
- {params} are specified as a series of ";X=y"