Python for Maemo

Overview
News
Applications
Screenshots
FAQ

Using it

Installation
Documentation
Components
Examples

Contributing

Project Page
Bugs
Patches
SVN
Wiki
Mailing List

Links

INdT
Python
Maemo

Python-GPSbt Documentation

Introduction

Python-GPSbt is a binding, based on libgpsbt, that provides access to GPS data through osso-gpsd. It only depends on a Bluetooth GPS device already paired.

How it works

Libgpsbt allows to connect with Bluetooth GPS devices and uses osso-gpsd daemon to provide a socket where you can send/receive information.

After a gps.start() its possible to send commands (trhough query) and receive data from GPS. Almost all information acquired from socket is stored inside a structure called 'fix'. To fill it just call the get_fix(). It does a query to get all necessary information from GPS device.

To finish the Bluetooth connection just call the gps.stop() method, providing the context (returned by gps.start()).

API

Example

The code below shows how to connect with a GPS device, get data and close this connection:

import gpsbt
import time

def main():
    context = gpsbt.start()

    if context == None:
        print 'Problem while connecting!'
        return

    # ensure that GPS device is ready to connect and to receive commands
    time.sleep(2)
    gpsdevice = gpsbt.gps()

    # read 3 times and show information
    for a in range(4):
        gpsdevice.get_fix()
        time.sleep(2)

        # print information stored under 'fix' variable
        print 'Altitude: %.3f'%gpsdevice.fix.altitude
        # dump all information available
        print gpsdevice

    # ends Bluetooth connection
    gpsbt.stop(context)

main()
        

Download source code here.

New releases

In a next version we hope to use GeoClue too and a new API, developed here at INdT. The idea is to have a layer providing all GPS related services until GeoClue gets mature enough and become Gnome's default GPS framework.