MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / __init__

Method __init__

wardriving.py:1335–1375  ·  view source on GitHub ↗
(self, shared_data)

Source from the content-addressed store, hash-verified

1333 rows = conn.execute(
1334 "SELECT * FROM cell_towers ORDER BY signal_dbm DESC"
1335 ).fetchall()
1336 return [dict(r) for r in rows]
1337 except Exception:
1338 return []
1339
1340 def get_zigbee_devices(self):
1341 """Get all discovered Zigbee / 802.15.4 devices."""
1342 with self._lock:
1343 try:
1344 with sqlite3.connect(self.db_path) as conn:
1345 conn.row_factory = sqlite3.Row
1346 rows = conn.execute(
1347 "SELECT * FROM zigbee_devices ORDER BY rssi DESC"
1348 ).fetchall()
1349 return [dict(r) for r in rows]
1350 except Exception:
1351 return []
1352
1353 def get_gps_track(self):
1354 """Return GPS track as list of [lat, lon] points."""
1355 with self._lock:
1356 try:
1357 with sqlite3.connect(self.db_path) as conn:
1358 rows = conn.execute(
1359 "SELECT latitude, longitude FROM gps_track ORDER BY timestamp"
1360 ).fetchall()
1361 return [[r[0], r[1]] for r in rows]
1362 except Exception:
1363 return []
1364
1365 def backfill_gps_from_track(self, max_gap_seconds=300):
1366 """Fill missing positions on networks / BT / cell rows by interpolating
1367 each row's first_seen timestamp against the gps_track table.
1368
1369 Handles the typical wardriving GPS gap: device discovered during the
1370 first ~minutes before fix lock, or during a brief reception dropout.
1371 Uses linear interpolation when bracketing trackpoints exist within
1372 max_gap_seconds on both sides; falls back to the nearest single
1373 trackpoint when only one side is close enough.
1374
1375 Returns dict {wifi, bluetooth, cells} of row counts backfilled.
1376 Invalidates the stats cache so subsequent reads reflect new positions.
1377 """
1378 import bisect

Callers

nothing calls this directly

Calls 1

setFunction · 0.50

Tested by

no test coverage detected