flockyou.py: bind host and listen port both read from env
(FLOCKYOU_HOST / FLOCKYOU_PORT, defaulting to 0.0.0.0:5000). Was a
hardcoded :5000 before, which collides with other Flask projects on
the same dev box — now you can run side-by-side instances or bind
to localhost only.
index.html: ?demo=1 query param seeds the dashboard with eight
synthetic detections covering every visual state (live wildcard-probe,
addr2, addr1 with/without GPS, replay/FLASH with/without GPS, replay/
RAM × 2) and reveals the device command toolbar so the polished layout
is browseable without flashing real hardware. Purely a front-end mock
— the command buttons still hit the real /api/flock/* endpoints, so
clicking them in demo mode produces the actual "device not connected"
error toast (that error path is itself part of the UI worth seeing).
Self-contained: a single initDemoMode() function gated on the query
param, called once at the end of DOMContentLoaded.
api/README.md: both features documented under Quick start so they're
discoverable without reading the source.
The first cut wedged the five host-command buttons into the existing
Sniffer device-control-group on the same line as the Connect /
Disconnect buttons. On a real-width header that crammed nine controls
into one row and the visual hierarchy collapsed.
Lift them out into a dedicated sticky toolbar that lives between the
header and the main content:
- Sticky top:0 with a frosted dark gradient, a soft shadow, and the
same #8b5cf6 accent the header already uses
- Sections separated by gradient dividers: DEVICE label + live
"Online" pulse dot, then [Pull Prev] [Pull Live] [Status], a
flexible spacer, divider, [Clear Prev] [Clear Live]
- SVG-iconed buttons (no emojis): download glyph on Pull, refresh
glyph on Pull Live, info-circle on Status, trash on Clear. 14px
stroked, currentColor so they pick up each button's accent
- Colour-keyed by action class: purple/indigo on Pull Prev (matches
the FLASH replay badge), cyan on Pull Live (matches the RAM
replay badge), slate on Status, red on the destructive Clear pair
- Slides in / out via transform + opacity transition when
setFlockExtraControls() toggles .show — no more raw display flip
Replay badges and the cards they live on got the same treatment so the
toolbar and the data it pulls back are visually linked:
- Inline SVG icons on the badge itself (a chip-stack glyph for
FLASH, a waveform for RAM) with a tooltip naming the source
CMD: that produced them
- Gradient backgrounds + subtle outer glow keyed to the same
indigo / cyan as the toolbar buttons
- Cards carry .replay (and .replay.live-source for RAM dumps) so
they get a coloured left border and a faint horizontal gradient
wash instead of a flat tint
Live progress counter while a Pull is in flight. Every replay_detection
socket event bumps a small pill on the in-flight button — "Pulling 17"
becomes "Pulling 18" in real time as the device streams the array.
Reset on the POST response or an error. Single global state since the
firmware protocol serializes one CMD:* at a time, so at most one Pull
is ever live.
Toast got a refresh too: bigger padding, frosted blur, a soft outer
glow matching the variant colour (green / amber / red / indigo), and
a smoother translate-in animation. The Status button now joins fields
with " · " instead of spaces so the one-line status line reads cleanly
at any width.
Buttons in the toolbar use .fcb-btn-label spans for their text so the
busy/done state updates ("Pulling…", "Querying…", "Clearing…") swap
just the label, not the SVG icon. Mobile breakpoint at 800px hides the
dividers and the Online dot, shrinks the label font, and lets the bar
wrap.
api/README.md was significantly out of date — referenced a non-existent
`app.py`, predated the entire `/api/flock/*` command-protocol surface,
and described the dashboard as if it only ingested live JSON.
Full rewrite:
- Quick start with the actual entrypoint (python flockyou.py)
- Sniffer command bar — table of all five buttons, what each one
sends to the device, what comes back, and the canonical
post-wardrive workflow (Pull Prev → Clear Prev) both as button
clicks and as curl invocations
- How replay detections are handled — no GPS temporal matching,
no overwrite of fresher live data, FLASH / RAM badges, the
flock_replay_complete socket event with its ok / count / reason
payload
- Toast colour semantics (green / blue / yellow / red)
- Endpoint reference table covering Sniffer, GPS, detections,
export/import, OUI lookup
- Socket.IO event table — both directions, with the new
flock_replay_complete / flock_status / flock_clear / flock_error
events from this branch
- JSON wire-format samples for live, replay, status, version,
replay_complete, clear, error
- Troubleshooting section keyed on the new failure modes (no_file /
crc_mismatch / device timeout / two-tabs-pulling-at-once)
The root README's "Running Flask" subsection gains a "Dashboard
command bar" block describing the same five buttons + replay visual
treatment, with a cross-reference to api/README.md for the full
detail.
Wires the host command endpoints added in the previous commit
(/api/flock/{status,dump_prev,dump_live,clear_prev,clear_live}) into
index.html as a five-button row under the Sniffer connect controls.
Buttons stay hidden until the device is connected and are auto-revealed
on the loadStatus() poll, the connect-success callback, and any
flock_reconnected socket event; hidden again on flock_disconnected.
- Pull Prev / Pull Live → POST dump_{prev,live}, show "Pulling…"
busy state, toast the final count
- Status → GET /api/flock/status, toast a compact
line: det=N ouis=N prev=yes ch=N heap=KKB
up=Ns
- Clear Prev / Clear Live → POST clear_{prev,live} after a confirm()
dialog (destructive)
A top-right toast element (#flockToast) handles all command feedback
with success/warning/error/info colour bands; auto-dismisses after 4s
(6s for status, so the user has time to read).
Replay detections are visually distinguished in the detection cards:
a new "FLASH" or "RAM" badge (purple for SPIFFS, blue for live RAM)
appears next to the GPS tag, and the card itself gets a subtle left
border + tint via .detection-item.replay.
Socket events also wired: replay_detection pushes into both
detections[] and cumulativeDetections[]; flock_replay_complete /
flock_error trigger their own toasts so other browser tabs see the
result of a pull triggered elsewhere; flock_status / flock_clear are
logged only (the REST caller already gets toast feedback).
All button click handlers disable the other command buttons during a
request so a user can't fire two dumps in parallel against the same
serial port (which would interleave at the firmware end — the protocol
serializes one CMD: at a time).
Firmware (main.cpp): adds a line-based CMD:* protocol on the same
USB-CDC port that already streams live detection JSON, so Flask can pull
state without re-flashing:
- CMD:STATUS emits {"event":"status",...} with det count,
SPIFFS state, free heap, uptime, channel
- CMD:VERSION emits firmware identifier + compile-time constants
- CMD:DUMP_LIVE streams the in-RAM detection table as replay
JSON lines, then a replay_complete sentinel
- CMD:DUMP_PREV same, but reads /prev_session.json from SPIFFS
(parses the CRC envelope and the embedded array)
- CMD:CLEAR_LIVE wipes fyDet[] and dirties the autosave
- CMD:CLEAR_PREV deletes /prev_session.json and any /session.tmp
Implementation:
- Minimal string-aware JSON object reader (string-aware brace counter,
backslash handling) lifts entries from the SPIFFS array one at a
time without slurping the whole file
- jsonGetString / jsonGetInt field extractors over flat objects
- emitReplayDetection() reuses the existing Flask schema and adds
replay / replay_source / detection_count / device_first_ms /
device_last_ms so the host can tell historical from live
- serialCmdTick() runs once per loop() and only acts on completed
lines — non-blocking and safe alongside the live detection path
- dualPrintf buffer bumped 384 → 1024 B to fit the longer replay line
(and to remove a latent truncation risk on a long-SSID live line)
Flask (api/flockyou.py): turns the protocol into REST endpoints and
ingests replayed detections without confusing them with live ones:
- flock_reader now dispatches {"event":"status"|"version"|"clear"|
"replay_complete"|"error"} responses to threading.Event slots, and
routes {"replay":true,"detection_method":...} lines through a new
add_replay_detection_from_serial() that skips GPS temporal matching,
flags timestamp_source="device_replay", and merges into an existing
fresher live entry instead of overwriting it
- send_command(cmd, response_event_name, timeout) serializes one
command at a time and blocks until the matching event arrives
- new endpoints: /api/flock/{status,version,dump_prev,dump_live,
clear_prev,clear_live}
Verified: pio run completes clean (RAM 19.1%, flash 12.0%); flockyou.py
passes py_compile. README documents the protocol, the per-event shape,
and the canonical post-wardrive dump_prev → clear_prev workflow.
Complete rewrite of standalone Flock-You firmware:
- Remove WiFi promiscuous mode, all detection is now BLE-only
- Add web dashboard served on AP "flockyou" at 192.168.4.1
- GPS wardriving via phone browser Geolocation API
- SPIFFS session persistence with auto-save every 60s
- Prior session tab (PREV) survives reboots
- KML export for Google Earth (current + prior session)
- JSON/CSV export with GPS coordinates
- Serial JSON output for Flask live ingestion
- Crow call boot sounds with detection/heartbeat alerts
- 200 unique device storage with FreeRTOS mutex
- Flask app: add KML import endpoint, GPS data handling
- Update platformio.ini with AsyncWebServer, ArduinoJson 7, SPIFFS partition
- Rewrite README to reflect current functionality