![]() |
2011-05-30
, 20:43
|
|
Posts: 1,648 |
Thanked: 2,122 times |
Joined on Mar 2007
@ UNKLE's Never Never Land
|
#2
|
global StartTime StartTime = time.time()
PastTime = time.time() - StartTime if PastTime >= GPSTIMEOUT: data.stop()
![]() |
2011-05-31
, 08:04
|
Posts: 27 |
Thanked: 17 times |
Joined on Jun 2010
|
#3
|
![]() |
2011-05-31
, 08:09
|
Posts: 141 |
Thanked: 41 times |
Joined on Apr 2011
@ Ahmedabad, India
|
#4
|
![]() |
2011-05-31
, 09:57
|
Posts: 214 |
Thanked: 140 times |
Joined on Aug 2010
|
#5
|
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)
I've followed the guide on http://wiki.maemo.org/PyMaemo/Using_Location_API. The purpose is to every 3rd hour connect with the GPS, fetch 10 coordinates and send them to my server. If I lose my phone I can always go to my server and find the coordinates of the phone. The script works fine, but the problem occurs when I enter a closed building without GPS-reception, then my phone tries forever until it finds GPS-reception which ofcourse drains the battery. So I'd like to implement a function that cancels the update if the script takes longer than 5 minutes. How can this be made?
Thanks!