Files
flock-you/src
Colonel Panic 3dc74c2b9d flockyou: bulletproof GPS tagging + atomic session persistence
Fix GPS not tagging all detections:
- Add dedicated fyGPSMutex guarding fyGPSLat/Lon/Acc/Valid/LastUpdate
- fyGPSSnapshot() + fyGPSUpdate() replace direct global reads/writes,
  eliminating the race between BLE callback (reader) and /api/gps
  HTTP handler (writer)
- fyBackfillGPS() runs every 2s in loop(), stamping any detection that
  was recorded before the first phone GPS fix became available
- BLE callback JSON emitter now uses snapshot instead of raw globals

Make data saving/transfer bulletproof:
- New envelope format: header line {v,count,bytes,crc32} + payload array
- CRC32 verification catches any truncation or corruption on read
- Atomic write: compute CRC pass 1, write tmp + verify, then rename to
  final (SPIFFS.rename with copy+delete fallback)
- Boot-time recovery: if session.json is missing/corrupt, recover from
  session.tmp; legacy raw-array files still load for back-compat
- Save cadence tightened: within 5s of first detection, after any new
  unique detection (3s throttle), and periodic safety net every 15s
- Export mutex timeouts raised 200->500ms to prevent empty CSV/JSON
  exports under heavy BLE traffic
- /api/history and /api/history/kml strip envelope header before
  returning body so downstream tools keep working unchanged

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 06:46:27 -04:00
..
2025-08-20 21:28:23 -04:00