Add live capture visuals: progress bar, blinking active targets, per-network state
- Progress bar under status line shows captured/total WPA targets - Three visual states per network: Green (pending) -> Orange blinking (active target) -> Red + checkmark (captured) - Active targets show live info: client count during observation, EAPOL progress during capture (e.g. "⚡ NetworkName 1/2") - Status line shows channel number and phase context - LVGL symbols: lightning bolt for active, checkmark for captured - Title updated to "⚡ Capture" with WiFi icon Made-with: Cursor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* WiFi Handshake Capture - ESP32-C6 1.47" LCD
|
||||
* Multi-target capture: up to 3 networks per channel, deauth all, capture all.
|
||||
* Display: green = not captured, red = captured.
|
||||
* Multi-target capture: up to 3 networks per channel.
|
||||
* Green = pending, orange blink = active target, red = captured.
|
||||
*/
|
||||
|
||||
#include "Display_ST7789.h"
|
||||
@@ -20,6 +20,90 @@ CaptureState captureState = STATE_SCANNING;
|
||||
unsigned long capture_start_time = 0;
|
||||
const unsigned long CHANNEL_TIMEOUT_MS = 30000;
|
||||
|
||||
// ─── Live capture visual update ───
|
||||
|
||||
void updateCaptureVisuals() {
|
||||
static unsigned long last_vis = 0;
|
||||
static bool blink = false;
|
||||
|
||||
unsigned long now = millis();
|
||||
if (now - last_vis < 400) return;
|
||||
last_vis = now;
|
||||
blink = !blink;
|
||||
|
||||
// Overall progress: captured / total WPA targets
|
||||
int captured = 0, total = 0;
|
||||
for (int i = 0; i < MAX_NETWORKS; i++) {
|
||||
if (networks[i].ssid.isEmpty()) break;
|
||||
if (!isCaptureable(i)) continue;
|
||||
total++;
|
||||
if (networks[i].handshake_captured) captured++;
|
||||
}
|
||||
Ui_SetProgress(captured, total);
|
||||
|
||||
// Per-network visual state
|
||||
for (int i = 0; i < MAX_NETWORKS; i++) {
|
||||
if (networks[i].ssid.isEmpty()) break;
|
||||
|
||||
// Is this network in an active capture slot?
|
||||
int si = -1;
|
||||
for (int s = 0; s < MAX_SLOTS; s++) {
|
||||
if (slots[s].active && slots[s].network_index == i) {
|
||||
si = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
char buf[48];
|
||||
|
||||
if (networks[i].handshake_captured) {
|
||||
// ✓ captured — red, static
|
||||
snprintf(buf, sizeof(buf), LV_SYMBOL_OK " %s", networks[i].ssid.c_str());
|
||||
Ui_SetNetworkText(i, buf);
|
||||
Ui_SetNetworkColor(i, lv_palette_main(LV_PALETTE_RED));
|
||||
}
|
||||
else if (si >= 0) {
|
||||
// ⚡ active target — orange, blinking
|
||||
CaptureSlot* slot = &slots[si];
|
||||
if (capturePhase == PHASE_OBSERVING) {
|
||||
snprintf(buf, sizeof(buf), LV_SYMBOL_CHARGE " %s +%dc",
|
||||
slot->ssid, slot->client_count);
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), LV_SYMBOL_CHARGE " %s %d/2",
|
||||
slot->ssid, slot->eapol_count);
|
||||
}
|
||||
Ui_SetNetworkText(i, buf);
|
||||
|
||||
lv_color_t color = blink ?
|
||||
lv_palette_main(LV_PALETTE_ORANGE) :
|
||||
lv_palette_darken(LV_PALETTE_ORANGE, 2);
|
||||
Ui_SetNetworkColor(i, color);
|
||||
}
|
||||
// else: pending — stays green from scan, no update needed
|
||||
}
|
||||
|
||||
// Status line reflects current phase
|
||||
static CapturePhase last_phase = PHASE_CAPTURING;
|
||||
if (capturePhase != last_phase) {
|
||||
if (capturePhase == PHASE_OBSERVING)
|
||||
Ui_SetWifiStatus("Mapping clients...");
|
||||
else
|
||||
Ui_SetWifiStatus("Capturing...");
|
||||
last_phase = capturePhase;
|
||||
}
|
||||
|
||||
static int last_eapol = -1;
|
||||
if (capturePhase == PHASE_CAPTURING && latest_eapol_count != last_eapol) {
|
||||
char ebuf[32];
|
||||
snprintf(ebuf, sizeof(ebuf), "Ch %d " LV_SYMBOL_CHARGE " EAPOL %d",
|
||||
current_channel, latest_eapol_count);
|
||||
Ui_SetWifiStatus(ebuf);
|
||||
last_eapol = latest_eapol_count;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Setup ───
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
LCD_Init();
|
||||
@@ -37,6 +121,8 @@ void setup() {
|
||||
captureState = STATE_SCANNING;
|
||||
}
|
||||
|
||||
// ─── Main loop ───
|
||||
|
||||
void loop() {
|
||||
Timer_Loop();
|
||||
handshakeCaptureProcessPending();
|
||||
@@ -44,6 +130,7 @@ void loop() {
|
||||
|
||||
switch (captureState) {
|
||||
case STATE_SCANNING: {
|
||||
Ui_ShowProgress(false);
|
||||
if (getCaptureableCount() == 0) {
|
||||
Ui_SetWifiStatus("Rescan");
|
||||
WiFiScanner_Refresh();
|
||||
@@ -54,7 +141,8 @@ void loop() {
|
||||
if (is_capturing) {
|
||||
captureState = STATE_CAPTURING;
|
||||
capture_start_time = millis();
|
||||
Ui_SetWifiStatus("Mapping clients");
|
||||
Ui_ShowProgress(true);
|
||||
Ui_SetWifiStatus("Mapping clients...");
|
||||
} else {
|
||||
Ui_SetWifiStatus("No targets");
|
||||
delay(1000);
|
||||
@@ -63,6 +151,8 @@ void loop() {
|
||||
}
|
||||
|
||||
case STATE_CAPTURING: {
|
||||
updateCaptureVisuals();
|
||||
|
||||
bool any_active = false;
|
||||
for (int i = 0; i < MAX_SLOTS; i++) {
|
||||
if (slots[i].active) {
|
||||
@@ -71,23 +161,8 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
// Phase-aware status display
|
||||
static CapturePhase last_shown_phase = PHASE_CAPTURING;
|
||||
if (capturePhase != last_shown_phase) {
|
||||
Ui_SetWifiStatus(capturePhase == PHASE_OBSERVING ? "Mapping clients" : "Capturing...");
|
||||
last_shown_phase = capturePhase;
|
||||
}
|
||||
|
||||
static int last_eapol = -1;
|
||||
if (capturePhase == PHASE_CAPTURING && latest_eapol_count != last_eapol) {
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "EAPOL %d/2", latest_eapol_count);
|
||||
Ui_SetWifiStatus(buf);
|
||||
last_eapol = latest_eapol_count;
|
||||
}
|
||||
|
||||
if (!any_active && getCaptureableCount() == 0) {
|
||||
Ui_SetWifiStatus("Done");
|
||||
Ui_SetWifiStatus(LV_SYMBOL_OK " All done");
|
||||
stopCapture();
|
||||
captureState = STATE_SCANNING;
|
||||
delay(2000);
|
||||
|
||||
Reference in New Issue
Block a user