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

Method _bt_scan_loop

wardriving.py:3067–3102  ·  view source on GitHub ↗

Background loop: scan for Bluetooth devices every ~15 seconds. Skipped while Huginn is streaming over serial — Huginn has a dedicated ESP32 BLE radio and the Pi's local bluetoothctl just re-imports BlueZ's all-time device cache, inflating unique counts. Piglet does not do BL

(self)

Source from the content-addressed store, hash-verified

3065 'file_size': size,
3066 'total_networks': total,
3067 'start_time': info.get('start_time', ''),
3068 'end_time': info.get('end_time', ''),
3069 })
3070 except Exception:
3071 sessions.append({'session_id': sid, 'error': 'corrupt'})
3072 return sessions
3073
3074 def wipe_all_data(self):
3075 """Delete all wardriving session databases. Requires wardriving to be stopped."""
3076 if self._running:
3077 return {'error': 'Cannot wipe data while wardriving is running. Stop first.'}
3078 wd_dir = os.path.join(self.data_dir, 'wardriving')
3079 if not os.path.isdir(wd_dir):
3080 return {'success': True, 'deleted': 0}
3081 deleted = 0
3082 for f in os.listdir(wd_dir):
3083 if f.startswith('session_') and f.endswith(('.db', '.db-wal', '.db-shm')):
3084 try:
3085 os.remove(os.path.join(wd_dir, f))
3086 deleted += 1
3087 except Exception as e:
3088 logger.warning(f"Failed to delete {f}: {e}")
3089 self.session = None
3090 logger.info(f"Wardriving data wiped: {deleted} files deleted")
3091 return {'success': True, 'deleted': deleted}
3092
3093 def _detect_wifi_interfaces(self, quiet=False):
3094 """Detect all available WiFi interfaces (including external USB adapters).
3095
3096 Enumerated from BOTH nmcli and sysfs and then UNIONed — never
3097 nmcli-with-sysfs-as-fallback. NetworkManager omits a radio entirely when
3098 it is unmanaged (Ragnar marks its own scan adapters unmanaged so NM
3099 doesn't add competing routes), left in monitor mode, or its driver
3100 loaded after NM started. Treating sysfs as a fallback that only runs
3101 when nmcli returned *nothing* silently dropped exactly those adapters,
3102 so a third dongle never joined the sweep. sysfs is the authority on
3103 "this radio exists"; nmcli only adds names sysfs might miss.
3104 """
3105 found = set()

Callers

nothing calls this directly

Calls 8

_scan_bluetoothMethod · 0.95
infoMethod · 0.80
get_positionMethod · 0.80
upsert_bluetoothMethod · 0.80
warningMethod · 0.80
valuesMethod · 0.45
sleepMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected