feat(i2c): add remote file management for schedule scripts #1
+526
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remote File Management for Schedule Scripts via I2C
Summary
Add remote file management capabilities allowing the Raspberry Pi to upload, download, and delete schedule files (.wpi) on the Witty Pi 5 filesystem via I2C, without requiring USB mass storage access.
Motivation
Currently, managing schedule files requires either:
This feature enables programmatic file management from the Pi side, useful for:
Changes
New Files
src/file_admin.hsrc/file_admin.csrc/usb_msc_device.hModified Files
src/i2c.hsrc/i2c.csrc/usb_msc_device.cusb_msc_ensure_ejected()helper functionArchitecture & Key Design Decisions
1. Separate Module (No Circular Dependencies)
The
file_adminmodule is isolated fromscript.cto avoid circular dependencies:This keeps script parsing/scheduling logic separate from file management.
2. Protocol Consistency
New commands follow the existing delimiter-based protocol (
<field|field|CRC>):This matches existing
LIST_FILES(0xA0F1) andCHOOSE_SCRIPT(0xA159) patterns.3. Interface Functions (Proper Encapsulation)
Instead of
externdeclarations, buffer access is provided via accessor functions:This allows
file_admin.cto access buffers without exposing internal implementation details.4. Security Measures
build_filepath()rejects/and\in filenames/scheduledirectory only/scheduledirectory onlyschedule.wpi,.act,.skdwhen running5. Buffer Size Increase
Buffers increased from 1KB to 4KB to support larger schedule files:
_Static_assert6. USB MSC Coordination
Files operations automatically eject USB MSC if mounted to prevent filesystem corruption:
This follows the existing pattern used by
CHOOSE_SCRIPTandSYNC_CONFcommands.Protocol Details
Status Codes (written to I2C_ADMIN_CONTEXT 0x41)
Directory Restrictions
/scheduleonly/scheduleonlyLimitations
<,>,|Potential Breaking Changes to Examinate
modification of value of DOWNLOAD_BUFFER_SIZE and UPLOAD_BUFFER_SIZE