Only do measurements on selected bssids from Access Points page #4
No files matched your search
@@ -71,6 +71,29 @@ class Session:
|
|||||||
values.append(m.signals[bssid])
|
values.append(m.signals[bssid])
|
||||||
return points, values
|
return points, values
|
||||||
|
|
||||||
|
def get_points_and_values_multi(self, bssids: list[str]) -> tuple[list, list]:
|
||||||
|
"""
|
||||||
|
Extract (x,y) points and averaged dBm values across multiple BSSIDs.
|
||||||
|
|
||||||
|
For each measurement point, only the BSSIDs that were actually visible
|
||||||
|
at that location are included in the average — a BSSID that was out of
|
||||||
|
range at a particular point is excluded rather than dragging the average
|
||||||
|
down with a floor value. Points where none of the requested BSSIDs were
|
||||||
|
seen at all are skipped entirely.
|
||||||
|
|
||||||
|
When a single BSSID is passed this is identical to get_points_and_values().
|
||||||
|
"""
|
||||||
|
if len(bssids) == 1:
|
||||||
|
return self.get_points_and_values(bssids[0])
|
||||||
|
|
||||||
|
points, values = [], []
|
||||||
|
for m in self.measurements:
|
||||||
|
readings = [m.signals[b] for b in bssids if b in m.signals]
|
||||||
|
if readings:
|
||||||
|
points.append((m.x, m.y))
|
||||||
|
values.append(sum(readings) / len(readings))
|
||||||
|
return points, values
|
||||||
|
|
||||||
def save(self, path: str):
|
def save(self, path: str):
|
||||||
"""Save session to JSON file."""
|
"""Save session to JSON file."""
|
||||||
data = {
|
data = {
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ class WiFiHeatmapApp:
|
|||||||
|
|
||||||
self.session: Session = Session()
|
self.session: Session = Session()
|
||||||
self.session_path: Optional[str] = None
|
self.session_path: Optional[str] = None
|
||||||
self.selected_bssid: Optional[str] = None # active on heatmap tab
|
|
||||||
self.scanning = False
|
self.scanning = False
|
||||||
self.last_scan: list[AccessPoint] = []
|
self.last_scan: list[AccessPoint] = []
|
||||||
self.selected_bssids: set[str] = set() # checked on AP tab
|
self.selected_bssids: set[str] = set() # checked on AP tab
|
||||||
|
self.selected_bssids_for_heatmap: list[str] = [] # ordered list for rendering
|
||||||
|
|
||||||
self._build_ui()
|
self._build_ui()
|
||||||
self._apply_styles()
|
self._apply_styles()
|
||||||
@@ -357,20 +357,33 @@ class WiFiHeatmapApp:
|
|||||||
self.selected_bssids.add(bssid)
|
self.selected_bssids.add(bssid)
|
||||||
else:
|
else:
|
||||||
self.selected_bssids.discard(bssid)
|
self.selected_bssids.discard(bssid)
|
||||||
|
self._sync_heatmap_bssids()
|
||||||
self._update_heatmap_ap_selector()
|
self._update_heatmap_ap_selector()
|
||||||
|
|
||||||
def _ap_select_all(self):
|
def _ap_select_all(self):
|
||||||
self.selected_bssids = {ap.bssid for ap in self.last_scan}
|
self.selected_bssids = {ap.bssid for ap in self.last_scan}
|
||||||
for row in self._ap_row_widgets:
|
for row in self._ap_row_widgets:
|
||||||
row["check_var"].set(True)
|
row["check_var"].set(True)
|
||||||
|
self._sync_heatmap_bssids()
|
||||||
self._update_heatmap_ap_selector()
|
self._update_heatmap_ap_selector()
|
||||||
|
|
||||||
def _ap_deselect_all(self):
|
def _ap_deselect_all(self):
|
||||||
self.selected_bssids.clear()
|
self.selected_bssids.clear()
|
||||||
for row in self._ap_row_widgets:
|
for row in self._ap_row_widgets:
|
||||||
row["check_var"].set(False)
|
row["check_var"].set(False)
|
||||||
|
self._sync_heatmap_bssids()
|
||||||
self._update_heatmap_ap_selector()
|
self._update_heatmap_ap_selector()
|
||||||
|
|
||||||
|
def _sync_heatmap_bssids(self):
|
||||||
|
"""Keep selected_bssids_for_heatmap in sync with the AP tab checkboxes.
|
||||||
|
Preserves a stable order: scan order first, then session-only BSSIDs."""
|
||||||
|
ordered = [ap.bssid for ap in self.last_scan if ap.bssid in self.selected_bssids]
|
||||||
|
scan_set = {ap.bssid for ap in self.last_scan}
|
||||||
|
for bssid in self.session.get_all_bssids():
|
||||||
|
if bssid in self.selected_bssids and bssid not in scan_set:
|
||||||
|
ordered.append(bssid)
|
||||||
|
self.selected_bssids_for_heatmap = ordered
|
||||||
|
|
||||||
# ── Heatmap Tab ───────────────────────────────────────────────────────────
|
# ── Heatmap Tab ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
def _build_heatmap_tab(self):
|
def _build_heatmap_tab(self):
|
||||||
@@ -424,40 +437,58 @@ class WiFiHeatmapApp:
|
|||||||
self._pending_scan: Optional[list[AccessPoint]] = None
|
self._pending_scan: Optional[list[AccessPoint]] = None
|
||||||
|
|
||||||
def _build_heatmap_right(self, f: tk.Frame):
|
def _build_heatmap_right(self, f: tk.Frame):
|
||||||
# ── Active AP selector ────────────────────────────────────────────────
|
# ── Active AP display ─────────────────────────────────────────────────
|
||||||
tk.Label(f, text="ACTIVE ACCESS POINT", font=("Courier", 8, "bold"),
|
tk.Label(f, text="ACTIVE NETWORKS", font=("Courier", 8, "bold"),
|
||||||
bg=BG2, fg=TEXT_DIM).grid(row=0, column=0, sticky="w", padx=14, pady=(14, 2))
|
bg=BG2, fg=TEXT_DIM).grid(row=0, column=0, sticky="w", padx=14, pady=(14, 2))
|
||||||
|
|
||||||
ap_note = tk.Label(f,
|
tk.Label(f,
|
||||||
text="Select networks on the Access Points tab\nto make them available here.",
|
text="Check networks on the Access\nPoints tab to include them here.\n"
|
||||||
font=("Courier", 7), bg=BG2, fg=TEXT_DIM, justify="left", wraplength=230)
|
"1 selected = single BSSID mode.\n"
|
||||||
ap_note.grid(row=1, column=0, sticky="w", padx=14, pady=(0, 6))
|
"2+ selected = averaged mode.",
|
||||||
|
font=("Courier", 7), bg=BG2, fg=TEXT_DIM, justify="left", wraplength=230
|
||||||
|
).grid(row=1, column=0, sticky="w", padx=14, pady=(0, 6))
|
||||||
|
|
||||||
ap_combo_frame = tk.Frame(f, bg=BG2)
|
# Scrollable list showing the currently active BSSIDs
|
||||||
ap_combo_frame.grid(row=2, column=0, sticky="ew", padx=10, pady=(0, 8))
|
active_frame = tk.Frame(f, bg=BG3, relief="flat",
|
||||||
ap_combo_frame.columnconfigure(0, weight=1)
|
highlightthickness=1,
|
||||||
|
highlightbackground=BORDER)
|
||||||
|
active_frame.grid(row=2, column=0, sticky="ew", padx=10, pady=(0, 4))
|
||||||
|
active_frame.columnconfigure(0, weight=1)
|
||||||
|
|
||||||
self.heatmap_ap_var = tk.StringVar()
|
active_scroll = ttk.Scrollbar(active_frame, orient="vertical")
|
||||||
self.heatmap_ap_combo = ttk.Combobox(ap_combo_frame,
|
active_scroll.grid(row=0, column=1, sticky="ns")
|
||||||
textvariable=self.heatmap_ap_var,
|
|
||||||
font=("Courier", 8), state="readonly", width=28)
|
|
||||||
self.heatmap_ap_combo.grid(row=0, column=0, sticky="ew")
|
|
||||||
self.heatmap_ap_combo.bind("<<ComboboxSelected>>", self._on_heatmap_ap_select)
|
|
||||||
|
|
||||||
ttk.Separator(f, orient="horizontal").grid(row=99, column=0, sticky="ew", padx=8, pady=6)
|
self.active_bssid_listbox = tk.Listbox(
|
||||||
|
active_frame,
|
||||||
|
font=("Courier", 7), bg=BG3, fg=ACCENT2,
|
||||||
|
relief="flat", borderwidth=0,
|
||||||
|
highlightthickness=0,
|
||||||
|
activestyle="none", height=5,
|
||||||
|
selectbackground=BG3, selectforeground=ACCENT2,
|
||||||
|
yscrollcommand=active_scroll.set)
|
||||||
|
self.active_bssid_listbox.grid(row=0, column=0, sticky="ew")
|
||||||
|
active_scroll.config(command=self.active_bssid_listbox.yview)
|
||||||
|
|
||||||
|
self.heatmap_mode_label = tk.Label(f, text="",
|
||||||
|
font=("Courier", 7, "bold"), bg=BG2, fg=WARNING,
|
||||||
|
wraplength=230, justify="left")
|
||||||
|
self.heatmap_mode_label.grid(row=3, column=0, sticky="w", padx=14, pady=(2, 4))
|
||||||
|
|
||||||
|
ttk.Separator(f, orient="horizontal").grid(row=4, column=0, sticky="ew", padx=8, pady=6)
|
||||||
|
|
||||||
# ── Measurements list (full remaining height) ──────────────────────
|
# ── Measurements list (full remaining height) ──────────────────────
|
||||||
tk.Label(f, text="MEASUREMENTS", font=("Courier", 8, "bold"),
|
tk.Label(f, text="MEASUREMENTS", font=("Courier", 8, "bold"),
|
||||||
bg=BG2, fg=TEXT_DIM).grid(row=100, column=0, sticky="w", padx=14, pady=(4, 2))
|
bg=BG2, fg=TEXT_DIM).grid(row=5, column=0, sticky="w", padx=14, pady=(4, 2))
|
||||||
|
|
||||||
self.meas_count_label = tk.Label(f, text="0 points collected",
|
self.meas_count_label = tk.Label(f, text="0 points collected",
|
||||||
font=("Courier", 8), bg=BG2, fg=ACCENT2)
|
font=("Courier", 8), bg=BG2, fg=ACCENT2)
|
||||||
self.meas_count_label.grid(row=101, column=0, sticky="w", padx=14, pady=(0, 4))
|
self.meas_count_label.grid(row=6, column=0, sticky="w", padx=14, pady=(0, 4))
|
||||||
|
|
||||||
meas_frame = tk.Frame(f, bg=BG2)
|
meas_frame = tk.Frame(f, bg=BG2)
|
||||||
meas_frame.grid(row=3, column=0, sticky="nsew", padx=8, pady=(0, 4))
|
meas_frame.grid(row=7, column=0, sticky="nsew", padx=8, pady=(0, 4))
|
||||||
meas_frame.columnconfigure(0, weight=1)
|
meas_frame.columnconfigure(0, weight=1)
|
||||||
meas_frame.rowconfigure(0, weight=1)
|
meas_frame.rowconfigure(0, weight=1)
|
||||||
|
f.rowconfigure(7, weight=1)
|
||||||
|
|
||||||
meas_scroll = ttk.Scrollbar(meas_frame, orient="vertical")
|
meas_scroll = ttk.Scrollbar(meas_frame, orient="vertical")
|
||||||
meas_scroll.grid(row=0, column=1, sticky="ns")
|
meas_scroll.grid(row=0, column=1, sticky="ns")
|
||||||
@@ -476,43 +507,33 @@ class WiFiHeatmapApp:
|
|||||||
font=("Courier", 8), bg=BG3, fg=DANGER,
|
font=("Courier", 8), bg=BG3, fg=DANGER,
|
||||||
relief="flat", padx=8, pady=4, cursor="hand2",
|
relief="flat", padx=8, pady=4, cursor="hand2",
|
||||||
command=self._delete_measurement)
|
command=self._delete_measurement)
|
||||||
self.del_meas_btn.grid(row=4, column=0, sticky="w", padx=12, pady=(0, 10))
|
self.del_meas_btn.grid(row=8, column=0, sticky="w", padx=12, pady=(0, 10))
|
||||||
|
|
||||||
# ── AP selector on Heatmap tab ────────────────────────────────────────────
|
# ── Active BSSID display on Heatmap tab ───────────────────────────────────
|
||||||
|
|
||||||
def _update_heatmap_ap_selector(self):
|
def _update_heatmap_ap_selector(self):
|
||||||
"""Rebuild the combobox from currently selected BSSIDs."""
|
"""Reflect the current AP tab selection in the Heatmap tab status panel."""
|
||||||
entries = []
|
self._sync_heatmap_bssids()
|
||||||
for ap in self.last_scan:
|
bssids = self.selected_bssids_for_heatmap
|
||||||
if ap.bssid in self.selected_bssids:
|
|
||||||
entries.append(f"{ap.ssid} [{ap.bssid}]")
|
|
||||||
|
|
||||||
# Also include session BSSIDs not in last scan
|
self.active_bssid_listbox.delete(0, tk.END)
|
||||||
scan_bssids = {ap.bssid for ap in self.last_scan}
|
|
||||||
for bssid in self.session.get_all_bssids():
|
if not bssids:
|
||||||
if bssid in self.selected_bssids and bssid not in scan_bssids:
|
self.active_bssid_listbox.insert(tk.END, " — none selected —")
|
||||||
|
self.heatmap_mode_label.config(
|
||||||
|
text="⚠ No networks selected.\nGo to Access Points tab and\ncheck at least one.",
|
||||||
|
fg=DANGER)
|
||||||
|
else:
|
||||||
|
for bssid in bssids:
|
||||||
ssid = self.session.get_ssid(bssid)
|
ssid = self.session.get_ssid(bssid)
|
||||||
entries.append(f"{ssid} [{bssid}]")
|
self.active_bssid_listbox.insert(tk.END, f" {ssid} {bssid}")
|
||||||
|
if len(bssids) == 1:
|
||||||
self.heatmap_ap_combo["values"] = entries
|
self.heatmap_mode_label.config(
|
||||||
|
text=f"Mode: single BSSID", fg=ACCENT2)
|
||||||
if not entries:
|
|
||||||
self.heatmap_ap_combo.set("— No APs selected (go to Access Points tab) —")
|
|
||||||
self.selected_bssid = None
|
|
||||||
else:
|
else:
|
||||||
# Keep current selection if still available
|
self.heatmap_mode_label.config(
|
||||||
current = self.heatmap_ap_var.get()
|
text=f"Mode: averaging {len(bssids)} BSSIDs", fg=WARNING)
|
||||||
if current not in entries:
|
|
||||||
self.heatmap_ap_combo.current(0)
|
|
||||||
self._on_heatmap_ap_select(None)
|
|
||||||
else:
|
|
||||||
self.heatmap_ap_combo.set(current)
|
|
||||||
|
|
||||||
def _on_heatmap_ap_select(self, event):
|
|
||||||
val = self.heatmap_ap_var.get()
|
|
||||||
m = __import__("re").search(r'\[([0-9A-Fa-f:]{17})\]', val)
|
|
||||||
if m:
|
|
||||||
self.selected_bssid = m.group(1).upper()
|
|
||||||
self._redraw()
|
self._redraw()
|
||||||
|
|
||||||
# ── Scanning (AP Tab) ─────────────────────────────────────────────────────
|
# ── Scanning (AP Tab) ─────────────────────────────────────────────────────
|
||||||
@@ -542,6 +563,7 @@ class WiFiHeatmapApp:
|
|||||||
if not self.selected_bssids:
|
if not self.selected_bssids:
|
||||||
self.selected_bssids = {ap.bssid for ap in aps}
|
self.selected_bssids = {ap.bssid for ap in aps}
|
||||||
self._populate_ap_table(aps)
|
self._populate_ap_table(aps)
|
||||||
|
self._sync_heatmap_bssids()
|
||||||
self._update_heatmap_ap_selector()
|
self._update_heatmap_ap_selector()
|
||||||
self._set_status(f"Scan complete — {len(aps)} networks found")
|
self._set_status(f"Scan complete — {len(aps)} networks found")
|
||||||
|
|
||||||
@@ -559,7 +581,7 @@ class WiFiHeatmapApp:
|
|||||||
|
|
||||||
def _begin_placement_mode(self):
|
def _begin_placement_mode(self):
|
||||||
if self.scanning: return
|
if self.scanning: return
|
||||||
if not self.selected_bssids:
|
if not self.selected_bssids_for_heatmap:
|
||||||
messagebox.showinfo("No APs Selected",
|
messagebox.showinfo("No APs Selected",
|
||||||
"Please select at least one access point\non the Access Points tab first.")
|
"Please select at least one access point\non the Access Points tab first.")
|
||||||
self.notebook.select(self.ap_tab)
|
self.notebook.select(self.ap_tab)
|
||||||
@@ -626,9 +648,9 @@ class WiFiHeatmapApp:
|
|||||||
# ── Rendering ─────────────────────────────────────────────────────────────
|
# ── Rendering ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
def _redraw(self):
|
def _redraw(self):
|
||||||
if self.selected_bssid:
|
if self.selected_bssids_for_heatmap:
|
||||||
try:
|
try:
|
||||||
render_heatmap(self.session, self.selected_bssid, self.fig, self.ax)
|
render_heatmap(self.session, self.selected_bssids_for_heatmap, self.fig, self.ax)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.ax.clear()
|
self.ax.clear()
|
||||||
self.ax.text(0.5, 0.5, f"Render error:\n{e}",
|
self.ax.text(0.5, 0.5, f"Render error:\n{e}",
|
||||||
@@ -659,10 +681,14 @@ class WiFiHeatmapApp:
|
|||||||
for y in range(0, h + 1, spacing):
|
for y in range(0, h + 1, spacing):
|
||||||
self.ax.axhline(y, color="#1e2a4a", linewidth=0.5)
|
self.ax.axhline(y, color="#1e2a4a", linewidth=0.5)
|
||||||
|
|
||||||
if not self.selected_bssids:
|
if not self.selected_bssids_for_heatmap:
|
||||||
msg = "← Select networks on the\nAccess Points tab first"
|
msg = "← Select networks on the\nAccess Points tab first"
|
||||||
else:
|
else:
|
||||||
msg = "Select a network in the\ndropdown above, then\nclick ▶ Scan & Place"
|
n = len(self.selected_bssids_for_heatmap)
|
||||||
|
msg = (f"{n} BSSID{'s' if n > 1 else ''} selected.\n"
|
||||||
|
f"Click ▶ Scan & Place to begin.")
|
||||||
|
if n > 1:
|
||||||
|
msg = f"Averaging {n} BSSIDs.\n" + msg
|
||||||
if not self.session.floorplan_path:
|
if not self.session.floorplan_path:
|
||||||
msg += "\n\n⚠ No floorplan — adding one\nincreases accuracy."
|
msg += "\n\n⚠ No floorplan — adding one\nincreases accuracy."
|
||||||
|
|
||||||
@@ -679,7 +705,7 @@ class WiFiHeatmapApp:
|
|||||||
if not messagebox.askyesno("New Session", "Discard current session?"): return
|
if not messagebox.askyesno("New Session", "Discard current session?"): return
|
||||||
self.session = Session(name="New Session")
|
self.session = Session(name="New Session")
|
||||||
self.session_path = None
|
self.session_path = None
|
||||||
self.selected_bssid = None
|
self.selected_bssids_for_heatmap = []
|
||||||
self._refresh_everything()
|
self._refresh_everything()
|
||||||
self._set_status("New session started")
|
self._set_status("New session started")
|
||||||
|
|
||||||
@@ -736,14 +762,14 @@ class WiFiHeatmapApp:
|
|||||||
self.floorplan_note.config(text="⚠ Adding a floorplan\nincreases accuracy.")
|
self.floorplan_note.config(text="⚠ Adding a floorplan\nincreases accuracy.")
|
||||||
|
|
||||||
def _export_png(self):
|
def _export_png(self):
|
||||||
if not self.selected_bssid:
|
if not self.selected_bssids_for_heatmap:
|
||||||
messagebox.showinfo("Export", "Select an access point first."); return
|
messagebox.showinfo("Export", "Select at least one access point first."); return
|
||||||
path = filedialog.asksaveasfilename(title="Export Heatmap",
|
path = filedialog.asksaveasfilename(title="Export Heatmap",
|
||||||
defaultextension=".png",
|
defaultextension=".png",
|
||||||
filetypes=[("PNG Image", "*.png"), ("JPEG Image", "*.jpg")])
|
filetypes=[("PNG Image", "*.png"), ("JPEG Image", "*.jpg")])
|
||||||
if path:
|
if path:
|
||||||
try:
|
try:
|
||||||
render_heatmap(self.session, self.selected_bssid, export_path=path)
|
render_heatmap(self.session, self.selected_bssids_for_heatmap, export_path=path)
|
||||||
self._set_status(f"Exported: {os.path.basename(path)}")
|
self._set_status(f"Exported: {os.path.basename(path)}")
|
||||||
messagebox.showinfo("Export", f"Saved to:\n{path}")
|
messagebox.showinfo("Export", f"Saved to:\n{path}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
+24
-12
@@ -31,7 +31,7 @@ SIGNAL_CMAP = mcolors.LinearSegmentedColormap.from_list("wifi_signal", SIGNAL_CO
|
|||||||
|
|
||||||
def render_heatmap(
|
def render_heatmap(
|
||||||
session: Session,
|
session: Session,
|
||||||
bssid: str,
|
bssids: list[str],
|
||||||
fig: Optional[Figure] = None,
|
fig: Optional[Figure] = None,
|
||||||
ax: Optional[Axes] = None,
|
ax: Optional[Axes] = None,
|
||||||
alpha: float = 0.65,
|
alpha: float = 0.65,
|
||||||
@@ -40,11 +40,13 @@ def render_heatmap(
|
|||||||
export_path: Optional[str] = None,
|
export_path: Optional[str] = None,
|
||||||
) -> tuple[Figure, Axes, Optional[HeatmapData]]:
|
) -> tuple[Figure, Axes, Optional[HeatmapData]]:
|
||||||
"""
|
"""
|
||||||
Render a heatmap for a specific BSSID onto a matplotlib figure.
|
Render a heatmap for one or more BSSIDs onto a matplotlib figure.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
session: The data session with measurements.
|
session: The data session with measurements.
|
||||||
bssid: The BSSID to visualize.
|
bssids: List of BSSIDs to visualize. If more than one, signal
|
||||||
|
values are averaged per measurement point (only BSSIDs
|
||||||
|
actually visible at each point contribute to the average).
|
||||||
fig/ax: Existing figure/axes to draw onto (creates new if None).
|
fig/ax: Existing figure/axes to draw onto (creates new if None).
|
||||||
alpha: Transparency of the heatmap overlay.
|
alpha: Transparency of the heatmap overlay.
|
||||||
show_points: Whether to draw measurement dot markers.
|
show_points: Whether to draw measurement dot markers.
|
||||||
@@ -54,15 +56,27 @@ def render_heatmap(
|
|||||||
Returns:
|
Returns:
|
||||||
(figure, axes, heatmap_data)
|
(figure, axes, heatmap_data)
|
||||||
"""
|
"""
|
||||||
|
if not bssids:
|
||||||
|
raise ValueError("At least one BSSID must be provided.")
|
||||||
|
|
||||||
if fig is None or ax is None:
|
if fig is None or ax is None:
|
||||||
fig, ax = plt.subplots(figsize=(10, 7))
|
fig, ax = plt.subplots(figsize=(10, 7))
|
||||||
|
|
||||||
ax.clear()
|
ax.clear()
|
||||||
|
|
||||||
points, values = session.get_points_and_values(bssid)
|
points, values = session.get_points_and_values_multi(bssids)
|
||||||
ssid = session.get_ssid(bssid)
|
|
||||||
w, h = session.canvas_width, session.canvas_height
|
w, h = session.canvas_width, session.canvas_height
|
||||||
|
|
||||||
|
# Build a human-readable label for the title
|
||||||
|
if len(bssids) == 1:
|
||||||
|
ssid = session.get_ssid(bssids[0])
|
||||||
|
ap_label = f"{ssid} • {bssids[0]}"
|
||||||
|
else:
|
||||||
|
# Show the shared SSID if all BSSIDs share one, otherwise list count
|
||||||
|
ssids = list({session.get_ssid(b) for b in bssids})
|
||||||
|
ssid = ssids[0] if len(ssids) == 1 else f"{len(ssids)} networks"
|
||||||
|
ap_label = f"{ssid} • {len(bssids)} BSSIDs averaged"
|
||||||
|
|
||||||
# ── Draw background ───────────────────────────────────────────────────────
|
# ── Draw background ───────────────────────────────────────────────────────
|
||||||
if session.floorplan_path:
|
if session.floorplan_path:
|
||||||
try:
|
try:
|
||||||
@@ -105,14 +119,12 @@ def render_heatmap(
|
|||||||
# ── Not enough points yet — show progress indicator ────────────────
|
# ── Not enough points yet — show progress indicator ────────────────
|
||||||
collected = len(points)
|
collected = len(points)
|
||||||
remaining = MIN_POINTS - collected
|
remaining = MIN_POINTS - collected
|
||||||
|
|
||||||
# Progress bar drawn as text blocks
|
|
||||||
filled = "█" * collected
|
filled = "█" * collected
|
||||||
empty = "░" * remaining
|
empty = "░" * remaining
|
||||||
bar = f"[{filled}{empty}] {collected}/{MIN_POINTS}"
|
bar = f"[{filled}{empty}] {collected}/{MIN_POINTS}"
|
||||||
|
|
||||||
msg = (
|
msg = (
|
||||||
f"Collecting data for '{ssid}'\n\n"
|
f"Collecting data\n\n"
|
||||||
f"{bar}\n\n"
|
f"{bar}\n\n"
|
||||||
f"Add {remaining} more point{'s' if remaining != 1 else ''} to generate the heatmap.\n"
|
f"Add {remaining} more point{'s' if remaining != 1 else ''} to generate the heatmap.\n"
|
||||||
f"Measurement dots are shown below."
|
f"Measurement dots are shown below."
|
||||||
@@ -126,19 +138,20 @@ def render_heatmap(
|
|||||||
|
|
||||||
# ── Draw measurement points ───────────────────────────────────────────────
|
# ── Draw measurement points ───────────────────────────────────────────────
|
||||||
if show_points and points:
|
if show_points and points:
|
||||||
for i, ((px, py), dbm) in enumerate(zip(points, values)):
|
for (px, py), dbm in zip(points, values):
|
||||||
color = SIGNAL_CMAP((dbm + 90) / 60)
|
color = SIGNAL_CMAP((dbm + 90) / 60)
|
||||||
circle = Circle((px, py), radius=max(w, h) * 0.012,
|
circle = Circle((px, py), radius=max(w, h) * 0.012,
|
||||||
facecolor=color, edgecolor='white',
|
facecolor=color, edgecolor='white',
|
||||||
linewidth=1.5, zorder=5, alpha=0.95)
|
linewidth=1.5, zorder=5, alpha=0.95)
|
||||||
ax.add_patch(circle)
|
ax.add_patch(circle)
|
||||||
ax.text(px, py - max(w, h) * 0.022, f"{dbm}",
|
ax.text(px, py - max(w, h) * 0.022, f"{int(round(dbm))}",
|
||||||
ha='center', va='bottom', fontsize=7, color='white',
|
ha='center', va='bottom', fontsize=7, color='white',
|
||||||
fontweight='bold', zorder=6)
|
fontweight='bold', zorder=6)
|
||||||
|
|
||||||
# ── Labels & styling ──────────────────────────────────────────────────────
|
# ── Labels & styling ──────────────────────────────────────────────────────
|
||||||
ap_label = f"{ssid} • {bssid}"
|
|
||||||
point_note = f"{len(points)} measurement{'s' if len(points) != 1 else ''}"
|
point_note = f"{len(points)} measurement{'s' if len(points) != 1 else ''}"
|
||||||
|
if len(bssids) > 1:
|
||||||
|
point_note += f" • avg of {len(bssids)} BSSIDs"
|
||||||
if not session.floorplan_path:
|
if not session.floorplan_path:
|
||||||
point_note += " ⚠ No floorplan — adding one increases accuracy"
|
point_note += " ⚠ No floorplan — adding one increases accuracy"
|
||||||
|
|
||||||
@@ -169,7 +182,6 @@ def _draw_grid_background(ax: Axes, w: int, h: int):
|
|||||||
for y in range(0, h + 1, grid_spacing):
|
for y in range(0, h + 1, grid_spacing):
|
||||||
ax.axhline(y, color='#1e2a4a', linewidth=0.6, zorder=0)
|
ax.axhline(y, color='#1e2a4a', linewidth=0.6, zorder=0)
|
||||||
|
|
||||||
# Label grid coordinates lightly
|
|
||||||
for x in range(0, w + 1, grid_spacing * 2):
|
for x in range(0, w + 1, grid_spacing * 2):
|
||||||
ax.text(x, h - 4, str(x), ha='center', va='bottom',
|
ax.text(x, h - 4, str(x), ha='center', va='bottom',
|
||||||
fontsize=6, color='#2a3a5a')
|
fontsize=6, color='#2a3a5a')
|
||||||
|
|||||||
Reference in new issue
Block a user