12 Commits
8 changed files with 193 additions and 105 deletions

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 KiB

After

Width:  |  Height:  |  Size: 334 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 KiB

After

Width:  |  Height:  |  Size: 929 KiB

+4 -4
View File
@@ -7,8 +7,8 @@ VSVersionInfo(
ffi=FixedFileInfo( ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0. Must always contain 4 elements. # Set not needed items to zero 0. Must always contain 4 elements.
filevers=(2026,5,0,0), filevers=(2026,5,2,0),
prodvers=(2026,5,0,0), prodvers=(2026,5,2,0),
# Contains a bitmask that specifies the valid bits 'flags'r # Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f, mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file. # Contains a bitmask that specifies the Boolean attributes of the file.
@@ -32,12 +32,12 @@ VSVersionInfo(
u'040904B0', u'040904B0',
[StringStruct(u'CompanyName', u''), [StringStruct(u'CompanyName', u''),
StringStruct(u'FileDescription', u'pyFi: WiFi Heatmap Generator'), StringStruct(u'FileDescription', u'pyFi: WiFi Heatmap Generator'),
StringStruct(u'FileVersion', u'2026.5.0.0'), StringStruct(u'FileVersion', u'2026.5.2.0'),
StringStruct(u'InternalName', u'pyFi'), StringStruct(u'InternalName', u'pyFi'),
StringStruct(u'LegalCopyright', u'© iamdoubz'), StringStruct(u'LegalCopyright', u'© iamdoubz'),
StringStruct(u'OriginalFilename', u'pyFi.exe'), StringStruct(u'OriginalFilename', u'pyFi.exe'),
StringStruct(u'ProductName', u'pyFi'), StringStruct(u'ProductName', u'pyFi'),
StringStruct(u'ProductVersion', u'2026.5.0.0')]) StringStruct(u'ProductVersion', u'2026.5.2.0')])
]), ]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
] ]
+1 -1
View File
@@ -460,7 +460,7 @@ class WiFiHeatmapApp:
text_fg = TEXT if is_live else dim_fg text_fg = TEXT if is_live else dim_fg
dim2 = TEXT_DIM if is_live else dim_fg dim2 = TEXT_DIM if is_live else dim_fg
_cell(ssid[:20], 160, fg=text_fg, bold=True) _cell(ssid, 160, fg=text_fg, bold=True)
_cell(bssid, 145, fg=dim2) _cell(bssid, 145, fg=dim2)
_cell(channel, 38, fg=text_fg) _cell(channel, 38, fg=text_fg)
_cell(freq, 90, fg=text_fg) _cell(freq, 90, fg=text_fg)
+176 -96
View File
@@ -1,6 +1,15 @@
""" """
renderer.py — Renders WiFi heatmaps using matplotlib. renderer.py — Renders WiFi heatmaps using matplotlib.
Supports both floorplan overlay and grid-only mode. Supports both floorplan overlay and grid-only mode.
Ekahau-style rendering:
- Colormap runs red (strongest) → orange → yellow → green → teal → blue →
violet (weakest), matching professional site survey tools.
- Alpha channel is derived per-pixel from signal strength so strong-signal
zones are opaque and weak/absent zones fade to transparent, revealing the
floorplan or grid beneath. This produces the "bubble" zone appearance.
- A Gaussian smoothing pass is applied to the RGBA image to soften the
zone edges and blend overlapping coverage areas naturally.
""" """
import numpy as np import numpy as np
@@ -9,26 +18,36 @@ import matplotlib.colors as mcolors
from matplotlib.figure import Figure from matplotlib.figure import Figure
from matplotlib.axes import Axes from matplotlib.axes import Axes
from matplotlib.patches import Circle from matplotlib.patches import Circle
from scipy.ndimage import gaussian_filter
from typing import Optional from typing import Optional
from PIL import Image from PIL import Image
from data import Session, Measurement from data import Session
from interpolator import interpolate, HeatmapData, get_signal_at from interpolator import interpolate, HeatmapData
# Custom colormap: black (no signal) → dark navy → blue → cyan → green → yellow → red (strong) # ── Colormaps ─────────────────────────────────────────────────────────────────
# Black occupies the very bottom so "not found" markers read naturally against the scale.
SIGNAL_COLORS = [ # Ekahau-style: red (excellent) → orange → yellow → green → teal → blue → violet (poor)
(0.00, 0.00, 0.00), # no signal: black ← new # This is the reverse of our old colormap — strong signal is warm, weak is cool.
(0.05, 0.05, 0.35), # very weak: dark navy _EKAHAU_COLORS = [
(0.10, 0.40, 0.80), # weak: blue (0.45, 0.00, 0.55), # -90 dBm violet / purple
(0.10, 0.80, 0.80), # moderate: cyan (0.10, 0.10, 0.80), # -80 dBm blue
(0.20, 0.90, 0.20), # good: green (0.00, 0.60, 0.80), # -70 dBm teal
(1.00, 0.90, 0.10), # strong: yellow (0.10, 0.80, 0.30), # -65 dBm green
(1.00, 0.40, 0.00), # very strong: orange (0.70, 0.95, 0.10), # -58 dBm yellow-green
(0.90, 0.05, 0.05), # excellent: red (1.00, 0.85, 0.00), # -52 dBm yellow
(1.00, 0.50, 0.00), # -46 dBm orange
(0.95, 0.10, 0.10), # -30 dBm red
] ]
SIGNAL_CMAP = mcolors.LinearSegmentedColormap.from_list("wifi_signal", SIGNAL_COLORS) SIGNAL_CMAP = mcolors.LinearSegmentedColormap.from_list("ekahau", _EKAHAU_COLORS)
# Separate single-color black cmap used only for the "no signal" dot markers
_BLACK_CMAP = mcolors.LinearSegmentedColormap.from_list("black_only",
[(0,0,0), (0,0,0)])
# dBm range the colormap spans
VMIN, VMAX = -90, -30
def render_heatmap( def render_heatmap(
@@ -36,24 +55,27 @@ def render_heatmap(
bssids: list[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.85,
show_points: bool = True, show_points: bool = True,
show_colorbar: bool = True, show_colorbar: bool = True,
export_path: Optional[str] = None, export_path: Optional[str] = None,
) -> tuple[Figure, Axes, Optional[HeatmapData]]: ) -> tuple[Figure, Axes, Optional[HeatmapData]]:
""" """
Render a heatmap for one or more BSSIDs onto a matplotlib figure. Render an Ekahau-style heatmap for one or more BSSIDs.
The heatmap is composited as an RGBA image where:
- RGB = signal strength mapped through the Ekahau colormap
- Alpha = derived from signal strength so strong zones are opaque and
weak/absent zones fade to transparent, revealing the background.
Args: Args:
session: The data session with measurements. session: The data session with measurements.
bssids: List of BSSIDs to visualize. If more than one, signal bssids: List of BSSIDs. Multiple BSSIDs are averaged per point.
values are averaged per measurement point (only BSSIDs fig/ax: Existing figure/axes (creates new if None).
actually visible at each point contribute to the average). alpha: Maximum opacity of the heatmap overlay (default 0.85).
fig/ax: Existing figure/axes to draw onto (creates new if None). show_points: Draw measurement dot markers.
alpha: Transparency of the heatmap overlay. show_colorbar: Draw the dBm color scale.
show_points: Whether to draw measurement dot markers. export_path: If set, save figure to this path.
show_colorbar: Whether to draw the dBm color scale.
export_path: If set, saves figure to this path.
Returns: Returns:
(figure, axes, heatmap_data) (figure, axes, heatmap_data)
@@ -63,115 +85,124 @@ def render_heatmap(
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))
fig.subplots_adjust(right=0.88)
# Remove any colorbars left over from previous renders. # Remove stale colorbar axes from previous renders
# Colorbars attach to the figure, not the axes, so ax.clear() doesn't touch them. for ax_obj in fig.axes[1:]:
for ax_obj in fig.axes[1:]: # axes[0] is the main plot; everything else is a colorbar
ax_obj.remove() ax_obj.remove()
ax.clear() ax.clear()
points, values = session.get_points_and_values_multi(bssids) points, values = session.get_points_and_values_multi(bssids)
missing_points = session.get_missing_points(bssids) # positions with no signal missing_points = session.get_missing_points(bssids)
w, h = session.canvas_width, session.canvas_height w, h = session.canvas_width, session.canvas_height
# Build a human-readable label for the title # ── Title label ───────────────────────────────────────────────────────────
if len(bssids) == 1: if len(bssids) == 1:
ssid = session.get_ssid(bssids[0]) ssid = session.get_ssid(bssids[0])
ap_label = f"{ssid} • {bssids[0]}" ap_label = f"{ssid} • {bssids[0]}"
else: else:
# Show the shared SSID if all BSSIDs share one, otherwise list count ssids = list({session.get_ssid(b) for b in bssids})
ssids = list({session.get_ssid(b) for b in bssids}) ssid = ssids[0] if len(ssids) == 1 else f"{len(ssids)} networks"
ssid = ssids[0] if len(ssids) == 1 else f"{len(ssids)} networks"
ap_label = f"{ssid} • {len(bssids)} BSSIDs averaged" ap_label = f"{ssid} • {len(bssids)} BSSIDs averaged"
# ── Draw background ─────────────────────────────────────────────────────── # ── Background ────────────────────────────────────────────────────────────
ax.set_facecolor('#1a1a1a')
fig.patch.set_facecolor('#0d0d1a')
if session.floorplan_path: if session.floorplan_path:
try: try:
img = Image.open(session.floorplan_path).convert("RGBA") fp_img = Image.open(session.floorplan_path).convert("RGBA")
img = img.resize((w, h), Image.LANCZOS) fp_img = fp_img.resize((w, h), Image.LANCZOS)
ax.imshow(np.array(img), extent=[0, w, h, 0], aspect='auto', zorder=1) ax.imshow(np.array(fp_img), extent=[0, w, h, 0],
aspect='auto', zorder=1)
except Exception as e: except Exception as e:
_draw_grid_background(ax, w, h) _draw_grid_background(ax, w, h)
print(f"[renderer] Could not load floorplan: {e}") print(f"[renderer] Could not load floorplan: {e}")
else: else:
_draw_grid_background(ax, w, h) _draw_grid_background(ax, w, h)
# ── Heatmap ───────────────────────────────────────────────────────────────
heatmap_data = None heatmap_data = None
MIN_POINTS = 4 # must match interpolator.MIN_POINTS_FOR_INTERPOLATION MIN_POINTS = 4
if len(points) >= MIN_POINTS: if len(points) >= MIN_POINTS:
# ── Interpolate & draw heatmap ─────────────────────────────────────
heatmap_data = interpolate(points, values, w, h) heatmap_data = interpolate(points, values, w, h)
img_heatmap = ax.imshow( grid = heatmap_data.grid_z # shape (res, res), dBm values
heatmap_data.grid_z,
extent=[0, w, 0, h], # Build RGBA image from the interpolated grid
origin='upper', rgba = _build_ekahau_rgba(grid, alpha)
cmap=SIGNAL_CMAP,
vmin=-90, # Dummy imshow used only to attach the colorbar scalar mappable
vmax=-30, # (not visible — alpha=0 on the axes imshow, real image via ax.imshow below)
alpha=alpha, _sm = ax.imshow(
zorder=2, grid,
aspect='auto' extent=[0, w, 0, h], origin='upper',
cmap=SIGNAL_CMAP, vmin=VMIN, vmax=VMAX,
alpha=0, zorder=0, aspect='auto'
)
# The actual visible heatmap — RGBA with signal-driven alpha
ax.imshow(
rgba,
extent=[0, w, 0, h], origin='upper',
aspect='auto', zorder=2, interpolation='bilinear'
) )
if show_colorbar: if show_colorbar:
cbar = fig.colorbar(img_heatmap, ax=ax, fraction=0.03, pad=0.02) cax = fig.add_axes([0.91, 0.15, 0.02, 0.70])
cbar = fig.colorbar(_sm, cax=cax)
cbar.set_label("Signal Strength (dBm)", fontsize=10) cbar.set_label("Signal Strength (dBm)", fontsize=10)
cbar.ax.tick_params(labelsize=8) cbar.ax.tick_params(labelsize=8)
cbar.ax.text(1.4, -90, "Poor", transform=cbar.ax.get_yaxis_transform(), cbar.ax.text(1.4, VMIN, "Poor",
transform=cbar.ax.get_yaxis_transform(),
fontsize=7, color='gray', va='bottom') fontsize=7, color='gray', va='bottom')
cbar.ax.text(1.4, -30, "Excellent", transform=cbar.ax.get_yaxis_transform(), cbar.ax.text(1.4, VMAX, "Excellent",
transform=cbar.ax.get_yaxis_transform(),
fontsize=7, color='gray', va='top') fontsize=7, color='gray', va='top')
# Black swatch at the very bottom representing "no signal found" cbar.ax.text(1.4, VMIN - 5, "No signal",
cbar.ax.text(1.4, -95, "No signal", transform=cbar.ax.get_yaxis_transform(), transform=cbar.ax.get_yaxis_transform(),
fontsize=7, color='black', va='top', fontsize=7, color='black', va='top',
bbox=dict(facecolor='white', edgecolor='none', pad=1.5)) bbox=dict(facecolor='white', edgecolor='none', pad=1.5))
else: else:
# ── Not enough points yet — show progress indicator ──────────────── # Progress indicator
collected = len(points) collected = len(points)
remaining = MIN_POINTS - collected remaining = MIN_POINTS - collected
filled = "█" * collected bar = f"[{'█' * collected}{'░' * remaining}] {collected}/{MIN_POINTS}"
empty = "░" * remaining msg = (f"Collecting data\n\n{bar}\n\n"
bar = f"[{filled}{empty}] {collected}/{MIN_POINTS}" f"Add {remaining} more point{'s' if remaining != 1 else ''} "
f"to generate the heatmap.")
msg = (
f"Collecting data\n\n"
f"{bar}\n\n"
f"Add {remaining} more point{'s' if remaining != 1 else ''} to generate the heatmap.\n"
f"Measurement dots are shown below."
)
ax.text(w / 2, h / 2, msg, ax.text(w / 2, h / 2, msg,
ha='center', va='center', fontsize=12, ha='center', va='center', fontsize=12,
color='#8888bb', linespacing=1.9, color='#8888bb', linespacing=1.9, fontfamily='monospace',
fontfamily='monospace', bbox=dict(boxstyle='round,pad=0.8',
bbox=dict(boxstyle='round,pad=0.8', facecolor='#10101e', alpha=0.8), facecolor='#10101e', alpha=0.8),
zorder=3) zorder=3)
# ── Draw measurement points ─────────────────────────────────────────────── # ── Measurement dots ──────────────────────────────────────────────────────
radius = max(w, h) * 0.012 radius = max(w, h) * 0.012
if show_points: if show_points:
# Valid signal points — colored by strength
for (px, py), dbm in zip(points, values): for (px, py), dbm in zip(points, values):
color = SIGNAL_CMAP((dbm + 90) / 60) norm_val = (dbm - VMIN) / (VMAX - VMIN)
color = SIGNAL_CMAP(norm_val)
ax.add_patch(Circle((px, py), radius=radius, ax.add_patch(Circle((px, py), radius=radius,
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.text(px, py - radius * 1.8, f"{int(round(dbm))}", ax.text(px, py - radius * 1.8, f"{int(round(dbm))}",
ha='center', va='bottom', fontsize=7, color='white', ha='center', va='bottom', fontsize=7,
fontweight='bold', zorder=6) color='white', fontweight='bold', zorder=6)
# Missing signal points — black circle with "?" label
for (px, py) in missing_points: for (px, py) in missing_points:
ax.add_patch(Circle((px, py), radius=radius, ax.add_patch(Circle((px, py), radius=radius,
facecolor='black', edgecolor='white', facecolor='black', edgecolor='white',
linewidth=1.5, zorder=5, alpha=0.95)) linewidth=1.5, zorder=5, alpha=0.95))
ax.text(px, py, "?", ax.text(px, py, "?",
ha='center', va='center', fontsize=7, color='white', ha='center', va='center', fontsize=7,
fontweight='bold', zorder=6) color='white', fontweight='bold', zorder=6)
# ── Labels & styling ────────────────────────────────────────────────────── # ── Labels & axes ─────────────────────────────────────────────────────────
total_points = len(points) + len(missing_points) total = len(points) + len(missing_points)
point_note = f"{total_points} measurement{'s' if total_points != 1 else ''}" point_note = f"{total} measurement{'s' if total != 1 else ''}"
if missing_points: if missing_points:
point_note += f" • {len(missing_points)} out of range (●)" point_note += f" • {len(missing_points)} out of range (●)"
if len(bssids) > 1: if len(bssids) > 1:
@@ -179,15 +210,13 @@ def render_heatmap(
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"
ax.set_title(f"WiFi Heatmap\n{ap_label}", fontsize=12, fontweight='bold', ax.set_title(f"WiFi Heatmap\n{ap_label}",
color='white', pad=10) fontsize=12, fontweight='bold', color='white', pad=10)
ax.set_xlabel(point_note, fontsize=9, color='#888888') ax.set_xlabel(point_note, fontsize=9, color='#888888')
ax.set_xlim(0, w) ax.set_xlim(0, w)
ax.set_ylim(h, 0) ax.set_ylim(h, 0)
ax.set_xticks([]) ax.set_xticks([])
ax.set_yticks([]) ax.set_yticks([])
ax.set_facecolor('#0d0d1a')
fig.patch.set_facecolor('#0d0d1a')
if export_path: if export_path:
fig.savefig(export_path, dpi=150, bbox_inches='tight', fig.savefig(export_path, dpi=150, bbox_inches='tight',
@@ -196,19 +225,70 @@ def render_heatmap(
return fig, ax, heatmap_data return fig, ax, heatmap_data
# ── RGBA builder ──────────────────────────────────────────────────────────────
def _build_ekahau_rgba(grid: np.ndarray, max_alpha: float) -> np.ndarray:
"""
Convert a dBm grid into an RGBA uint8 image with Ekahau-style rendering.
Alpha channel logic:
- Signal ≥ VMAX (-30 dBm) → fully opaque (max_alpha)
- Signal ≤ FADE_FLOOR → fully transparent
- Between → smooth cosine ramp so zone edges blend
naturally without a hard cutoff
A Gaussian blur is applied to the alpha channel before compositing so
overlapping coverage zones blend smoothly rather than showing sharp
interpolation triangle edges.
"""
FADE_FLOOR = -85.0 # dBm at which the overlay becomes fully transparent
BLUR_SIGMA = 8.0 # pixels — controls softness of zone edges
res_h, res_w = grid.shape
# ── RGB from colormap ─────────────────────────────────────────────────────
norm = np.clip((grid - VMIN) / (VMAX - VMIN), 0.0, 1.0)
rgb_float = SIGNAL_CMAP(norm)[:, :, :3] # (H, W, 3) float 0-1
# ── Alpha from signal strength ────────────────────────────────────────────
# Use a cosine ramp so the transition from opaque to transparent is smooth
# rather than linear (cosine gives a more natural "bubble" appearance).
fade_range = VMAX - FADE_FLOOR
t = np.clip((grid - FADE_FLOOR) / fade_range, 0.0, 1.0)
alpha_raw = 0.5 * (1.0 - np.cos(np.pi * t)) # cosine ease-in-out
# NaN cells (outside interpolation hull) → transparent
alpha_raw[np.isnan(grid)] = 0.0
# Gaussian blur softens zone boundaries and blends overlapping AP zones
alpha_blur = gaussian_filter(alpha_raw, sigma=BLUR_SIGMA)
alpha_blur = np.clip(alpha_blur * max_alpha, 0.0, max_alpha)
# ── Assemble RGBA uint8 ───────────────────────────────────────────────────
rgba = np.zeros((res_h, res_w, 4), dtype=np.uint8)
rgba[:, :, 0] = (rgb_float[:, :, 0] * 255).astype(np.uint8)
rgba[:, :, 1] = (rgb_float[:, :, 1] * 255).astype(np.uint8)
rgba[:, :, 2] = (rgb_float[:, :, 2] * 255).astype(np.uint8)
rgba[:, :, 3] = (alpha_blur * 255).astype(np.uint8)
return rgba
# ── Grid background ───────────────────────────────────────────────────────────
def _draw_grid_background(ax: Axes, w: int, h: int): def _draw_grid_background(ax: Axes, w: int, h: int):
"""Draw a subtle technical grid when no floorplan is available.""" """Draw a subtle coordinate grid when no floorplan is loaded."""
ax.set_facecolor('#0d0d1a') ax.set_facecolor('#1a1a1a')
grid_spacing = max(w, h) // 10 spacing = max(w, h) // 10
for x in range(0, w + 1, grid_spacing): for x in range(0, w + 1, spacing):
ax.axvline(x, color='#1e2a4a', linewidth=0.6, zorder=0) ax.axvline(x, color='#2a2a2a', linewidth=0.6, zorder=0)
for y in range(0, h + 1, grid_spacing): for y in range(0, h + 1, spacing):
ax.axhline(y, color='#1e2a4a', linewidth=0.6, zorder=0) ax.axhline(y, color='#2a2a2a', linewidth=0.6, zorder=0)
for x in range(0, w + 1, grid_spacing * 2): for x in range(0, w + 1, 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='#3a3a3a')
for y in range(0, h + 1, grid_spacing * 2): for y in range(0, h + 1, spacing * 2):
ax.text(2, y, str(y), ha='left', va='center', ax.text(2, y, str(y), ha='left', va='center',
fontsize=6, color='#2a3a5a') fontsize=6, color='#3a3a3a')
+12 -4
View File
@@ -293,9 +293,16 @@ def _wlanapi_enumerate_and_scan(wlan, handle) -> list[AccessPoint]:
("InterfaceInfo", WLAN_INTERFACE_INFO * 64)] ("InterfaceInfo", WLAN_INTERFACE_INFO * 64)]
# ── WLAN_BSS_ENTRY ──────────────────────────────────────────────────────── # ── WLAN_BSS_ENTRY ────────────────────────────────────────────────────────
# DOT11_SSID is { ULONG uSSIDLength; UCHAR ucSSID[32]; } = 36 bytes.
# It must NOT be packed as c_ubyte*33 — uSSIDLength is a 4-byte ULONG,
# not a single byte, so the SSID data starts at offset 4, not offset 1.
class DOT11_SSID(ctypes.Structure):
_fields_ = [("uSSIDLength", wt.ULONG),
("ucSSID", ctypes.c_ubyte * 32)]
class WLAN_BSS_ENTRY(ctypes.Structure): class WLAN_BSS_ENTRY(ctypes.Structure):
_fields_ = [ _fields_ = [
("dot11Ssid", ctypes.c_ubyte * 33), # DOT11_SSID (length + ucSSID) ("dot11Ssid", DOT11_SSID),
("uPhyId", wt.ULONG), ("uPhyId", wt.ULONG),
("dot11Bssid", ctypes.c_ubyte * 6), ("dot11Bssid", ctypes.c_ubyte * 6),
("dot11BssType", wt.DWORD), ("dot11BssType", wt.DWORD),
@@ -357,9 +364,10 @@ def _wlanapi_enumerate_and_scan(wlan, handle) -> list[AccessPoint]:
for j in range(bss_list.dwNumberOfItems): for j in range(bss_list.dwNumberOfItems):
entry = bss_list.wlanBssEntries[j] entry = bss_list.wlanBssEntries[j]
# Decode SSID (first byte = length in DOT11_SSID) # Decode SSID using the correct DOT11_SSID field layout:
ssid_len = entry.dot11Ssid[0] # uSSIDLength is the number of valid bytes in ucSSID (max 32).
ssid_bytes = bytes(entry.dot11Ssid[1:1 + ssid_len]) ssid_len = entry.dot11Ssid.uSSIDLength
ssid_bytes = bytes(entry.dot11Ssid.ucSSID[:ssid_len])
try: try:
ssid = ssid_bytes.decode("utf-8", errors="replace").strip("\x00") ssid = ssid_bytes.decode("utf-8", errors="replace").strip("\x00")
except Exception: except Exception: