Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces SD-card support to SmartFuseBox: periodic sensor snapshot logging to CSV, plus an SD-based configuration loader/exporter (C29/C30) and related system/status plumbing (warnings, system commands, JSON status).
Changes:
- Add
SdCardLoggerfor non-blocking SD logging with warning integration (missing/error). - Add
SdCardConfigLoaderto loadconfig.txtfrom SD at boot and support C29 (reload) / C30 (export). - Extend warning propagation and system/status endpoints to expose SD state and include warning masks in heartbeats.
Reviewed changes
Copilot reviewed 38 out of 39 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| SmartFuseBox/__vm/Upload.vmps.xml | Removed VisualMicro-generated upload metadata file. |
| SmartFuseBox/__vm/Compile.vmps.xml | Removed VisualMicro-generated compile metadata file. |
| SmartFuseBox/SystemNetworkHandler.h | Adds SD logger dependency wiring for system route. |
| SmartFuseBox/SystemNetworkHandler.cpp | Extends system status JSON to include SD presence + log size. |
| SmartFuseBox/SmartFuseBoxConstants.h | Adds SD SPI pin constants and light sensor analog pin. |
| SmartFuseBox/SmartFuseBox/SdCardConfigLoader.h | Adds a second SdCardConfigLoader declaration (duplicate copy). |
| SmartFuseBox/SmartFuseBox/SdCardConfigLoader.cpp | Adds a second SdCardConfigLoader implementation (duplicate copy). |
| SmartFuseBox/SmartFuseBox.vcxproj.filters | Adds SD-related files but introduces duplicated filter entries. |
| SmartFuseBox/SmartFuseBox.vcxproj | Adds SD logger/config loader sources and include paths for SPI/SdFat. |
| SmartFuseBox/SmartFuseBox.ino | Integrates SD logger, optional SD config load, changes LINK baud, resets serial on RX. |
| SmartFuseBox/SensorDataRecord.h | Introduces a standardized sensor record type (currently unused by logger). |
| SmartFuseBox/SdCardLogger.h | Declares SD logger (buffering, rotation, warnings, stats). |
| SmartFuseBox/SdCardLogger.cpp | Implements SD logger (snapshot capture, CSV writing, presence detection). |
| SmartFuseBox/SDCardConfigLoader.h | Declares SD config loader w/ coordinated access via SdCardLogger. |
| SmartFuseBox/SDCardConfigLoader.cpp | Implements SD config load/reload/export with logger release/reacquire. |
| SmartFuseBox/LightSensorHandler.h | Extends constructor to accept an analog pin. |
| SmartFuseBox/ConfigSyncManager.cpp | Switches a message from sendError to sendDebug. |
| SmartFuseBox/BluetoothSystemService.cpp | Removes Serial prints from BLE service init/notify. |
| Shared/WarningType.h | Adds SdCardError and SdCardMissing warning bits + strings. |
| Shared/WarningManager.h | Adds broadcastWarningChange() declaration. |
| Shared/WarningManager.cpp | Broadcasts warning deltas, includes local warnings in heartbeat, adds helper method. |
| Shared/ToneManager.cpp | Removes verbose Serial debug logging. |
| Shared/SystemFunctions.h | Adds resetSerial(Stream&) helper. |
| Shared/SystemDefinitions.h | Adds F8/F9 system cmds and C29/C30 config cmds. |
| Shared/Sensors/GpsSensorHandler.h | Improves GPS time sync to support partial date/time validity. |
| Shared/DateTimeManager.cpp | Formatting-only brace/indentation adjustments. |
| Shared/CommandHandlers/SystemCommandHandler.h | Adds SD logger wiring to system command handler (UNO R4). |
| Shared/CommandHandlers/SystemCommandHandler.cpp | Adds F8/F9 support; changes F6 parsing behavior. |
| Shared/CommandHandlers/SensorCommandHandler.cpp | Expands query handling and adds debug messages. |
| Shared/CommandHandlers/ConfigCommandHandler.h | Adds SD config loader wiring (C29/C30). |
| Shared/CommandHandlers/ConfigCommandHandler.cpp | Implements C29/C30 commands and SD loader integration. |
| Shared/CommandHandlers/AckCommandHandler.cpp | Silences unused parameter warning. |
| SD_CONFIG_README.md | Adds end-user documentation for SD config loader. |
| SD_CONFIG_IMPLEMENTATION.md | Adds implementation guide (some now outdated given code changes). |
| Commands.md | Documents new F8/F9 and C29/C30 (contains a command example typo). |
| BoatControlPanel/BoatControlPanel.vcxproj.filters | Adjusts BaseSensor include entry to local path. |
| BoatControlPanel/BoatControlPanel.vcxproj | Adjusts include path and BaseSensor include to local file. |
| BoatControlPanel/BoatControlPanel.ino | Aligns LINK baud to 19200 and uses SystemFunctions::resetSerial. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #pragma once | ||
|
|
||
| #include <Arduino.h> | ||
| #include <SdFat.h> | ||
| #include <SerialCommandManager.h> | ||
| #include "ConfigController.h" | ||
| #include "ConfigSyncManager.h" | ||
|
|
||
| constexpr char SD_CONFIG_FILENAME[] = "config.txt"; | ||
| constexpr uint16_t SD_CONFIG_MAX_LINE_LENGTH = 128; | ||
|
|
||
| /** | ||
| * @class SdCardConfigLoader | ||
| * @brief Loads configuration from SD card and applies to ConfigManager | ||
| * | ||
| * Boot sequence: | ||
| * 1. Check for SD card with config.txt | ||
| * 2. Parse and validate all commands | ||
| * 3. Compare with current EEPROM config | ||
| * 4. If different, apply changes and save to EEPROM |
There was a problem hiding this comment.
There are two SdCardConfigLoader implementations in the repo (SmartFuseBox/SDCardConfigLoader.* and SmartFuseBox/SmartFuseBox/SdCardConfigLoader.*). Keeping both is confusing and risks future build/include mistakes; consolidate to a single source of truth and remove the unused duplicate directory/files.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
No description provided.