REFACTORING : move tstamp into real scanner object
[wifihood] / wifiscanner / wifimap / replay.py
index 3d3113d..a0ccd46 100644 (file)
@@ -1,5 +1,4 @@
 
-import config
 import db
 
 import gobject
@@ -8,10 +7,9 @@ import os
 
 class ReplayScanner ( gobject.GObject ) :
 
-    def __init__ ( self , ifname="wlan0" ) :
+    def __init__ ( self , conf , ifname="wlan0" ) :
         gobject.GObject.__init__( self )
         self.scan_timeout = 0
-        conf = config.Configuration( 'scanner' )
         self.db = db.database( os.path.join( conf.homedir , "wifireplay.db" ) )
 
         # Values specific to replaying
@@ -28,14 +26,15 @@ class ReplayScanner ( gobject.GObject ) :
 
         # Values to be set by wireless scans
         self.scanlist = {}
-        self.tstamp = 0
         self.nscan = 0
         self.nfp = 0
 
         # Values from the Scanner object
+        self.tstamp = 0
         self.newap = 0
         self.newaps = False
         self.aps = {}
+        self.oldpos = {}
 
     def start ( self , timeout=5000 , writelog=False ) :
         self.scan_timeout = timeout
@@ -86,6 +85,8 @@ class ReplayScanner ( gobject.GObject ) :
                 if not self.aps.has_key( mac ) :
                     self.aps[ mac ] = [ 0 , 0 , 0 ]
                 self.db.add( mac , max_rss , self.tstamp , self.info[4:] )
+            if self.aps[mac][0] != 0 :
+                self.oldpos[mac] = self.aps[mac][1] / self.aps[mac][0] , self.aps[mac][2] / self.aps[mac][0]
             self.aps[mac][0] += 1
             self.aps[mac][1] += self.info[4]
             self.aps[mac][2] += self.info[5]