7.5. Communication with GPS and Other Devices

Besides mobile phones and PCs, there are many devices that can communicate over Bluetooth. Many of them support RFCOMM, so you can directly apply the code in this chapter to a large number of use cases.

7.5.1. Connecting to GPS over Bluetooth

In this section, we connect to an external Bluetooth GPS reader to acquire GPS data (see Figure 7.4).

Some modern mobile phones, such as Nokia N95, come with an integrated GPS receiver. You can use PyS60 to obtain information from the internal GPS, as described in Section 6.4. Unfortunately, accessing the internal GPS requires some capabilities that are not available for the self-signed PyS60 interpreter (see Appendix A for more information). In contrast, you can use an external GPS receiver without any special capabilities just by connecting to it over Bluetooth.

Data that comes from the external GPS receiver follows a standard specified by the National Marine Electronics Association (NMEA). You can find a description of this format in many sources on the web, for instance, at www.gpsinformation.org/dale/nmea.htm.

Figure 7-4. Bluetooth from phone to GPS

The format is line-oriented: the GPS sends one message per line. The line contains typically many fields, which are separated by commas. The line begins with the dollar sign, $, which is followed by a word that specifies the data type. The messages ...

Get Mobile Python: Rapid Prototyping of Applications on the Mobile Platform now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.