Revive project at new apartment — fixes, SSID update, gitignore
WiFi/firmware: - SSID updated to botnet in both node and ble_node config.h - Stale coordinator comment removed from node/config.h Coordinator fixes: - BLE-only nodes now visible in dashboard sidebar and node detail (build_nodes was querying beacon_events only; BLE nodes have no beacons) - ble_events and heartbeat_events added to pruning cycle - ble_events table added to ensure_schema() in dashboard - confidence column dropped from beacon_events (always 'high', never queried) - Ingestor commits batched per packet instead of per store call - wal_autocheckpoint=500 added to ingestor DB connection (writer was missing it) - python3 -u added to both service ExecStart lines (stdout was buffered, logs not appearing in journalctl) Repo hygiene: - .gitignore added (events.db, __pycache__, build artifacts) - events.db removed from git tracking - README updated: new apartment, node table, active investigations, BLE observations labelled as previous-location data, status checklist Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,7 @@ DB_PATH = os.path.join(os.path.dirname(__file__), "events.db")
|
||||
def init_db(path: str) -> sqlite3.Connection:
|
||||
conn = sqlite3.connect(path, check_same_thread=False)
|
||||
conn.execute("PRAGMA journal_mode=WAL")
|
||||
conn.execute("PRAGMA wal_autocheckpoint=500")
|
||||
conn.execute("""
|
||||
CREATE TABLE IF NOT EXISTS beacon_events (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -32,8 +33,7 @@ def init_db(path: str) -> sqlite3.Connection:
|
||||
rssi INTEGER,
|
||||
channel INTEGER,
|
||||
encryption TEXT,
|
||||
importance TEXT,
|
||||
confidence TEXT
|
||||
importance TEXT
|
||||
)
|
||||
""")
|
||||
conn.execute("""
|
||||
@@ -139,8 +139,8 @@ def init_db(path: str) -> sqlite3.Connection:
|
||||
def store_beacon(conn: sqlite3.Connection, ev: dict, received_at: str):
|
||||
conn.execute("""
|
||||
INSERT INTO beacon_events
|
||||
(received_at, node_id, node_ts, ssid, bssid, rssi, channel, encryption, importance, confidence)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
(received_at, node_id, node_ts, ssid, bssid, rssi, channel, encryption, importance)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", (
|
||||
received_at,
|
||||
ev.get("node_id"),
|
||||
@@ -151,7 +151,6 @@ def store_beacon(conn: sqlite3.Connection, ev: dict, received_at: str):
|
||||
ev.get("ch"),
|
||||
ev.get("enc"),
|
||||
ev.get("imp"),
|
||||
ev.get("conf"),
|
||||
))
|
||||
conn.commit()
|
||||
|
||||
@@ -174,7 +173,6 @@ def store_heartbeat(conn: sqlite3.Connection, ev: dict, received_at: str):
|
||||
ev.get("assoc_drops"),
|
||||
ev.get("ble_drops"),
|
||||
))
|
||||
conn.commit()
|
||||
|
||||
|
||||
def store_probe(conn: sqlite3.Connection, ev: dict, received_at: str):
|
||||
@@ -191,7 +189,6 @@ def store_probe(conn: sqlite3.Connection, ev: dict, received_at: str):
|
||||
ev.get("rssi"),
|
||||
ev.get("imp"),
|
||||
))
|
||||
conn.commit()
|
||||
|
||||
# ─── Validation ──────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -244,7 +241,6 @@ def store_deauth(conn: sqlite3.Connection, ev: dict, received_at: str):
|
||||
ev.get("reason"),
|
||||
ev.get("rssi"),
|
||||
))
|
||||
conn.commit()
|
||||
|
||||
|
||||
def validate_deauth(ev: dict) -> str | None:
|
||||
@@ -279,7 +275,6 @@ def store_assoc(conn: sqlite3.Connection, ev: dict, received_at: str):
|
||||
ev.get("ssid", ""),
|
||||
ev.get("rssi"),
|
||||
))
|
||||
conn.commit()
|
||||
|
||||
|
||||
def validate_assoc(ev: dict) -> str | None:
|
||||
@@ -312,7 +307,6 @@ def store_ble(conn: sqlite3.Connection, ev: dict, received_at: str):
|
||||
mfr_id if mfr_id is not None and mfr_id >= 0 else None,
|
||||
ev.get("mfr_data", ""),
|
||||
))
|
||||
conn.commit()
|
||||
|
||||
|
||||
def validate_ble(ev: dict) -> str | None:
|
||||
@@ -438,6 +432,8 @@ def handle_packet(data: bytes, addr: tuple, conn: sqlite3.Connection):
|
||||
color = IMP_COLOR.get(imp, "")
|
||||
print(f"{color}[{received_at}] {node} {ssid:<32} {bssid} ch{ch:<3} {rssi:>4}dBm {enc}{RESET}")
|
||||
|
||||
conn.commit()
|
||||
|
||||
# ─── Main ────────────────────────────────────────────────────────────────────
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user