AI Strategy: Wi-Fi Collapse Detection

Technical Brief for Development Team

This document outlines the machine learning pipeline for detecting Wi-Fi "Collapse" events (Hidden Node, Saturation, Interference) using ESP32 sensors. We utilize an LLM-Assisted Weak Supervision approach to overcome the lack of labeled training data.

🚀 The Core Concept

We cannot hard-code thresholds because RF environments vary wildly. Instead, we use Gemini (LLM) as a "Senior Network Engineer" to label raw logs, and then train a fast, lightweight model (Random Forest/XGBoost) to mimic that decision logic in real-time.

Phase 1: Firmware Data Engineering

The ESP32 firmware is the data generator. It must output time-series features suitable for ML, not just human-readable logs.

1. Feature Vector (The CSV)

Every 1 second, the firmware writes a CSV line to the internal storage partition. This is our feature set:

2. Storage Strategy

We use a custom partition table to allocate ~5-13MB for LittleFS/SPIFFS. NVS is strictly for config. This allows 24-72 hours of continuous logging.


Phase 2: The "Weak Supervision" Pipeline

We solve the "Cold Start Problem" (having data but no labels) by using Generative AI.

Step A: Context-Aware Capture

Technicians capture logs in known scenarios. The filename conveys the context:

Step B: LLM Labeling (Gemini)

We feed the raw CSV chunks to Gemini via API with a prompt that injects domain knowledge:

"Act as a Wi-Fi expert. Analyze this CSV log. This data represents a Hidden Node scenario. Look for periods where AvgNAV is high (>10ms) but AvgPHY remains normal, yet Retries spike. Label each timestamp row as 'Normal', 'Congestion', or 'Collapse'."

Result: A "Silver Standard" labeled dataset ready for supervised learning.


Phase 3: Training & Inference

Gemini is too slow for real-time packet analysis. We train a classical model for the actual work.

1. Model Selection

Algorithm: Random Forest Classifier or XGBoost.

2. Runtime Inference Architecture

Deployment Target: Linux Gateway / Edge Server.

  1. 1 ESP32 streams CSV lines via UDP (Broadcast/Unicast) to Linux.
  2. 2 Python script listens on UDP port.
  3. 3 Script loads pre-trained model.pkl.
  4. 4 Incoming CSV -> Feature Vector -> model.predict().
  5. 5 If Collapse_Prob > 0.8 for 3 consecutive seconds -> TRIGGER ALERT.