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

Method upsert_cell_tower

wardriving.py:623–650  ·  view source on GitHub ↗

Insert or update a detected cell tower.

(self, cell_id, mcc, mnc, lac, tech, provider,
                          signal_dbm, band_freq, lat, lon)

Source from the content-addressed store, hash-verified

621 old_lat = existing[3]
622 old_lon = existing[4]
623 pend_lat = existing[5]
624 pend_lon = existing[6]
625 pend_count = existing[7] or 0
626
627 # Update best position at strongest signal
628 new_best = rssi if rssi > old_best else old_best
629 best_lat_val = lat if (rssi > old_best and lat) else None
630 best_lon_val = lon if (rssi > old_best and lon) else None
631
632 # GPS drift protection for main lat/lon
633 update_lat = old_lat
634 update_lon = old_lon
635 new_pend_lat = pend_lat
636 new_pend_lon = pend_lon
637 new_pend_count = pend_count
638
639 if lat and lon:
640 if old_lat is None or old_lon is None:
641 # First GPS fix — accept immediately
642 update_lat = lat
643 update_lon = lon
644 new_pend_lat = None
645 new_pend_lon = None
646 new_pend_count = 0
647 else:
648 dist = self._haversine_m(old_lat, old_lon, lat, lon)
649 if dist < self.GPS_DRIFT_THRESHOLD_M:
650 # Same area — no change needed, reset pending
651 new_pend_lat = None
652 new_pend_lon = None
653 new_pend_count = 0

Callers 3

import_wigle_csvMethod · 0.95
_cell_scan_loopMethod · 0.80
_parse_serial_lineMethod · 0.80

Calls 4

debugMethod · 0.80
connectMethod · 0.45
fetchoneMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected