Skip to content

Improve detection scoring and expand surveillance OUI coverage#8

Merged
f1yaw4y merged 16 commits into
f1yaw4y:mainfrom
dougborg:pr/06-scoring-and-oui
Mar 8, 2026
Merged

Improve detection scoring and expand surveillance OUI coverage#8
f1yaw4y merged 16 commits into
f1yaw4y:mainfrom
dougborg:pr/06-scoring-and-oui

Conversation

@dougborg

@dougborg dougborg commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Stack order: 6/8 — merge after #7 (PR5: docs)

Summary

  • Tune WiFi/BLE scan parameters: capture probe responses, reduce channel dwell to 300ms, increase BLE duty cycle to 40%
  • Replace numeric scoring thresholds with flag-based alert tiers (CONFIRMED, SUSPICIOUS, NONE)
  • Add Flock Safety OUI detector (B4:1E:52 prefix) for direct hardware identification
  • Add broader surveillance camera OUI detection for common camera manufacturers
  • Fix detectorWeights out-of-bounds access for new OUI detectors

Test plan

  • Run make test and verify all unit tests pass including new OUI detector tests
  • Compile for M5StickC and verify alert tiers display correctly
  • Verify Flock Safety OUI (B4:1E:52) triggers CONFIRMED alert
  • Verify surveillance camera OUIs trigger SUSPICIOUS alert

🤖 Generated with Claude Code

dougborg and others added 16 commits February 2, 2026 00:48
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Provides per-variant build/upload/flash/monitor targets for all 6
hardware variants, plus LittleFS data upload for variants with audio
assets. Uses GNU Make define/eval/call to generate targets from a
single template.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tests compile natively with clang++/g++ — no ESP32 hardware needed.
Covers detectors, device tracker state machine, and threat analyzer
scoring pipeline (37 cases, 126 assertions) targeting the M5Stick
variant's pure-logic headers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move DetectorTypes.h, Detectors.h, DeviceSignatures.h, EventBus.h,
ThreatAnalyzer.h, and TelemetryReporter.h from the M5Stick variant's
src/ into a new top-level common/ directory. Update Makefile to pass
-I common via build.extra_flags for all variants, update test includes,
and fix the M5Stick FQBN (m5stick_c_plus2 -> m5stack_stickc_plus2).

Merge AudioEvent (from M5Fire's EventBus.h) into the shared header so
other variants can adopt it when migrated.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Delete local copies of EventBus.h, DeviceSignatures.h, ThreatAnalyzer.h,
and TelemetryReporter.h from m5fire/src/. Replace legacy ThreatAnalyzer
(simple boolean matching) and TelemetryReporter (DynamicJsonDocument with
nested objects) implementations with the shared detector-based system.

Add ISR-safe deferred event processing with portMUX spinlocks for WiFi,
BLE, and threat events. Add ThreatAnalyzer::tick() heartbeat in loop()
and shouldAlert gate on triggerAlert().

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Delete local copies of EventBus.h, DeviceSignatures.h, ThreatAnalyzer.h,
and TelemetryReporter.h from mini12864/src/. Replace legacy ThreatAnalyzer
and TelemetryReporter implementations with shared detector-based system.

Add ISR-safe deferred event processing with portMUX spinlocks. Move
display notifications (Mini12864DisplayNotifyWifiFrame, ShowAlert) and
audio playback to the main loop's deferred handlers. Add tick() heartbeat
and shouldAlert gate.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Also fix Makefile build.extra_flags override that was clobbering
ESP32 core defines (-DESP32=ESP32 etc). Use build.defines instead,
which is included within build.extra_flags and starts empty.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move variant-specific src/ files into sketch directory to follow
Arduino convention. Keep Flipper's own TelemetryReporter (line-based
protocol for Flipper app). Fix radioType null-check for char array.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Dockerfile builds a debian:bookworm-slim image containing arduino-cli,
ESP32 core v3.0.7, all Arduino libraries (version-pinned), doctest.h,
and pre-warmed core caches for all 4 FQBNs. Source is bind-mounted at
runtime so the image is reusable across branches.

Also adds docker-compose.yml (build-all, test, shell, build-variant
services), entrypoint.sh (seeds doctest.h into bind-mount), .dockerignore,
and Makefile docker-* targets.

Fixes a portability bug in test/mocks/Arduino.h: adds <cstdio> for
snprintf, which macOS clang resolves transitively but Debian clang-14
does not.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Audit all dependency versions against latest available in the Arduino
library index, update where possible, and centralize pins in a single
versions.env file consumed by both Makefile (include) and Dockerfile
(--build-arg).

Version changes:
- Base image: debian:bookworm-slim → debian:trixie-slim (Debian 13)
- arduino-cli: unpinned → 1.4.1
- ArduinoJson: 7.3.0 → 7.4.2
- NimBLE-Arduino: 2.2.1 → 2.3.7
- M5Unified: 0.2.2 → 0.2.11
- Adafruit SSD1306: 2.5.13 → 2.5.16
- doctest: 2.4.11 → 2.4.12
- ESP32 core: 3.0.7 (unchanged — newer causes IRAM overflow)
- U8g2: 2.35.30 (unchanged — already latest in Arduino index)
- Adafruit GFX: 1.12.4 (unchanged — already latest)

Makefile install-deps now pins library versions from versions.env,
matching what the Dockerfile installs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move duplicated content (setup, architecture, telemetry, configuration,
troubleshooting, extending) from 6 variant READMEs into 8 shared docs/
files. Add new docs for build system and testing (previously undocumented).
Restructure CLAUDE.md as a scannable agent gateway with dispatch table.
Fix incorrect .ino filename reference in portable variant README.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 2, 2026 08:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the detection scoring system from numeric thresholds to flag-based alert tiers, adds direct Flock Safety OUI detection (B4:1E:52), expands surveillance camera OUI coverage, and tunes WiFi/BLE scan parameters for improved detection. The changes also consolidate shared headers into common/, establish a comprehensive test suite, and introduce a build system with Makefile and Docker support.

Changes:

  • Replaces numeric certainty scoring with flag-based alert levels (CONFIRMED, SUSPICIOUS, INFO, NONE) determined by detector combinations
  • Adds dedicated Flock Safety OUI (B4:1E:52) and surveillance camera OUI detectors with curated manufacturer list
  • Reduces WiFi channel dwell time to 300ms, increases BLE scan duration to 2s, and adds probe response capture
  • Consolidates duplicated headers into common/ directory and adds comprehensive unit test suite with doctest
  • Introduces Makefile/Docker build system with pinned dependency versions in versions.env

Reviewed changes

Copilot reviewed 68 out of 71 changed files in this pull request and generated no comments.

Show a summary per file
File Description
common/DetectorTypes.h New detector flag system, alert levels, device tracking types
common/Detectors.h All detector functions including new Flock/surveillance OUI detectors
common/DeviceSignatures.h MAC OUI lists including Flock Safety and surveillance camera manufacturers
common/ThreatAnalyzer.h Complete rewrite with flag-based scoring, DeviceTracker, alert tier logic
common/TelemetryReporter.h Updated JSON output with detector breakdown and alert levels
common/EventBus.h ThreatEvent struct expanded with matchFlags, detectorWeights, alertLevel fields
test/*.cpp Comprehensive unit tests for detectors, device tracker, and threat analyzer
*/RadioScanner.h Scan timing tuned (300ms channel dwell, 2s BLE), probe response capture added
*/*.ino Thread-safe event processing, include path updates, alert logic using new tiers
Makefile Complete build automation for all variants, tests, LittleFS upload, Docker
Dockerfile Reproducible build environment with all dependencies pre-baked
versions.env Single source of truth for all dependency versions
docs/*.md Comprehensive documentation covering architecture, build system, testing, etc.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@f1yaw4y f1yaw4y merged commit 5a5a8c4 into f1yaw4y:main Mar 8, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants