Add JSON packet recording option to native#8930
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new feature to the Portduino (native) platform that allows decoded mesh packets to be recorded to a local JSON file. Users can configure a file path and optionally filter packets by port number (e.g., only save position, telemetry, or text message packets).
- Adds
JSONFileandJSONFilterconfiguration options to the YAML config - Implements file opening and packet writing logic for JSON recording
- Supports filtering by packet type using port number enums
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/platform/portduino/PortduinoGlue.h | Adds extern declaration for JSONFile stream, new config fields (JSONFilename and JSONFilter), and YAML serialization logic for the new config options |
| src/platform/portduino/PortduinoGlue.cpp | Implements file opening logic for JSONFile with error handling, and config parsing with string-to-enum conversion for filter values |
| src/mesh/Router.cpp | Adds packet recording logic in the decode path that writes JSON-serialized packets to the file when filtering criteria are met |
| bin/config-dist.yaml | Documents the new JSONFile and JSONFilter configuration options with example usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Should we handle log rotation/expiry? |
That would be a nice addition, yes. I think this could be merged without it, but some features around that idea would be nice. I even considered adding a way to get the timestamp in the file name. |
Add an option to dump decoded packets to a local file, in JSON format.