Skip to content

Comments

Add CRC error count endpoint with persistent SQLite storage#88

Open
dmduran12 wants to merge 1 commit intorightup:devfrom
dmduran12:feature/crc-error-count-endpoint
Open

Add CRC error count endpoint with persistent SQLite storage#88
dmduran12 wants to merge 1 commit intorightup:devfrom
dmduran12:feature/crc-error-count-endpoint

Conversation

@dmduran12
Copy link

Summary

Adds a new GET /api/crc_count?hours=24 endpoint that tracks and counts CRC errors detected by the SX1262 radio, with persistent SQLite storage.

Problem

CRC errors ([RX] CRC error detected - discarding packet) are logged by the radio driver but not tracked or queryable via the API. This makes it difficult to monitor radio health over time.

Changes

  • sqlite_handler.py — New crc_errors table with timestamp index, store_crc_error() and get_crc_error_count(hours) methods, cleanup in cleanup_old_data()
  • storage_collector.pyrecord_crc_error() and get_crc_error_count() pass-throughs (same pattern as noise_floor)
  • http_server.pyCRCErrorTracker logging handler that intercepts CRC error log messages from SX1262_wrapper and persists them to SQLite
  • main.py — Register _crc_tracker on root logger alongside _log_buffer
  • api_endpoints.py — New GET /api/crc_count?hours=24 endpoint
  • web/__init__.py — Export new symbols

Design

  • No pymc_core changes needed — intercepts existing log output via a logging.Handler
  • Follows the exact same pattern as the existing noise_floor feature (table, handler methods, storage pass-through, API endpoint)
  • Data automatically cleaned up by existing cleanup_old_data() retention policy
  • Uses the standard ?hours=24 time period parameter consistent with all other endpoints

Response Format

{
  "success": true,
  "data": {
    "crc_error_count": 42,
    "hours": 24,
    "oldest_event": 1707350239.044,
    "newest_event": 1707436639.044
  }
}

Co-Authored-By: Warp agent@warp.dev

- Add crc_errors table to SQLite with timestamp index
- Add store_crc_error() and get_crc_error_count() to SQLiteHandler
- Add record_crc_error() and get_crc_error_count() pass-throughs to StorageCollector
- Add CRCErrorTracker logging handler that intercepts SX1262_wrapper CRC error logs
- Add GET /api/crc_count?hours=24 endpoint following existing noise_floor pattern
- Include crc_errors in cleanup_old_data() for automatic data retention

Co-Authored-By: Warp <agent@warp.dev>
@dmduran12
Copy link
Author

this endpoint will allow reporting CRC errors in the dashboard @rightup

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.

1 participant