View Single Post
Posts: 214 | Thanked: 140 times | Joined on Aug 2010
#5
You know, you could use Google Latitude and ZapLoc to do this...

But anyway, in ZapLoc, I have two timers.

One timer in the main loop, which is the polling interval. Then, when that timeout calls its function, that function setts up a second timeout, which turns the GPS back off.

Note that timeouts using the gobject.timeout_add() function, if the function you call return True, it will loop and repeat your timeout, if it returns False, it will only happen once.

So roughtly, I have something like this:

Code:
def turn_off_gps(control):
     control.stop()
     return False

def start_gps(control):
    control.start()
    gobject.timeout_add(30000, turn_off_gps, control)
    return True

def init ():
   control =  ...
   gobject.timeout_add(120000, start_gps, control)
Roughly, this will start the GPS every two minutes, and keep it running for 30 seconds.

/Z