self.device.connect_object("changed", GPSObject.update , self)
# Values to be set by GPSDevice changed events
- self.gps_state = False
- self.gps_info = "NO_FIX", 0, 0, None, None, None, None, None, None, None
+ self.info = None, 0, 0, None, None, None, None
self.satellites = None
- self.cell_info = None
+ self.cells = None
self.ngps = 0
def set_method ( self , method="gps" ) :
def update ( self ) :
- self.gps_state = None
if self.device.online :
- if self.device.status == location.GPS_DEVICE_STATUS_NO_FIX :
- self.gps_state = "NO_FIX"
- elif self.device.status == location.GPS_DEVICE_STATUS_FIX :
- self.gps_state = "FIX"
+ if self.device.status == location.GPS_DEVICE_STATUS_FIX :
+ state = "FIX"
self.ngps += 1
elif self.device.status == location.GPS_DEVICE_STATUS_DGPS_FIX :
- self.gps_state = "DGPS"
-
- self.gps_info = self.gps_state , self.device.satellites_in_use , self.device.satellites_in_view , self.device.fix[2] , self.device.fix[4] , self.device.fix[5] , self.device.fix[7] , self.device.fix[9] , self.device.fix[11] , self.device.fix[13]
+ state = "DGPS"
+ # FIXME : Increase also ngps here ???
+ else :
+ state = None
+
+ lat , lon , alt = None , None , None
+ if self.device.fix[1] & location.GPS_DEVICE_LATLONG_SET:
+ lat , lon = device.fix[4:6]
+ if self.device.fix[1] & location.GPS_DEVICE_ALTITUDE_SET:
+ alt = device.fix[7]
+ # FIXME : get time from GPS fix
+ self.info = state , self.device.satellites_in_view , self.device.satellites_in_use , self.device.fix[2] , lat , lon , alt
self.satellites = self.device.satellites
- self.cell_info = self.device.cell_info
+ self.cells = self.device.cell_info
+ else :
+ self.info = None, 0, 0, None, None, None, None
def report ( self ) :
return "%d gps" % self.ngps
-# mode = device.fix[0]
-# if mode == location.GPS_DEVICE_MODE_NOT_SEEN : # This means ??
-# print "mode is NOSEEN"
-# if mode == location.GPS_DEVICE_MODE_NO_FIX : # This implies device.status == location.GPS_DEVICE_STATUS_NO_FIX
-# # and probably device.fix[1] == location.GPS_DEVICE_NONE_SET
-# print "mode is NOFIX"
-# if mode == location.GPS_DEVICE_MODE_2D :
-# print "mode is 2D"
-# if mode == location.GPS_DEVICE_MODE_3D :
-# print "mode is 3D"
-
-# if flags & location.GPS_DEVICE_SPEED_SET :
-# print "GPS_DEVICE_SPEED_SET"
-# if flags & location.GPS_DEVICE_TRACK_SET :
-# print "GPS_DEVICE_TRACK_SET"
-# if flags & location.GPS_DEVICE_ALTITUDE_SET :
-# print "GPS_DEVICE_ALTITUDE_SET"
-# if flags & location.GPS_DEVICE_CLIMB_SET :
-# print "GPS_DEVICE_CLIMB_SET"
-
gobject.type_register(GPSObject)
if __name__ == "__main__" :
def scan ( self ) :
wifiscan.WifiScanner.scan( self )
latlon = None
- if self.gps_state == "FIX" :
- latlon = self.gps_info[4] , self.gps_info[5] , self.gps_info[6]
+ if self.info :
+ latlon = self.info[4:]
for mac,max_rss in self.scanlist.iteritems() :
stored = self.db.get( mac )
if stored :
def write_logs ( self ) :
fd = open( os.path.join( conf.homedir , "wiscan_gui.info" ) , 'a' )
- fd.write( "%s %s %s\n" % ( self.tstamp , self.gps_info , self.scanlist ) )
+ fd.write( "%s %s %s\n" % ( self.tstamp , self.info , self.scanlist ) )
fd.close()
if self.satellites :
loclist = open( os.path.join( conf.homedir , "location.info" ) , 'a' )
loclist.write ( "%s\n" % ( self.satellites ,) )
loclist.close()
- if self.cell_info :
+ if self.cells :
celllist = open( os.path.join( conf.homedir , "cell.info" ) , 'a' )
- celllist.write ( "%s\n" % ( self.cell_info ,) )
+ celllist.write ( "%s\n" % ( self.cells ,) )
celllist.close()
def report ( self ) :
+ # BUG : if report is called after close, db.nrows() will produce an exception
return "%s\t%s\t%d ap\t%d total ap" % ( gps.GPSObject.report(self) , wifiscan.WifiScanner.report(self) , self.newap , self.db.nrows() )