Ping Guard and Voltage Sensor#188
Merged
Merged
Conversation
Closed
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces PinGuard (GPIO assignment validation) plus a crash-loop guard to recover from watchdog reboot loops caused by bad persisted pin configuration, and adds a new Voltage Sensor type + command/docs updates (including GPS config changes on ESP32).
Changes:
- Add PinGuard validation + system command
F14to configure PinGuard runtime mode, and integrate pin validation into multiple pin-setting paths (SPI/SD, relays, Nextion, etc.). - Add crash-loop detection using a persisted crash counter that triggers config reset to safe defaults after a threshold.
- Add a new
VoltageSensorimplementation (S23) and extend sensor/docs/test data for new/updated command formats.
Reviewed changes
Copilot reviewed 30 out of 32 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| TestData/test-commands.txt | Updates external sensor remove command format to use v=<idx>. |
| README.md | Documents PinGuard and crash-loop guard; links new PinGuard docs. |
| PowerControlHub/WarningType.h | Adds GpsInvalidConfig and LowVoltage warnings + display strings. |
| PowerControlHub/VoltageSensorHandler.h | Adds a new Voltage sensor handler that publishes S23 and raises LowVoltage. |
| PowerControlHub/SystemDefinitions.h | Adds F14 system command ID and S23 sensor command ID + new sensor enum value. |
| PowerControlHub/SystemCommandHandler.cpp | Implements F14 to persist/apply PinGuard mode flags. |
| PowerControlHub/SensorFactory.h | Adds Voltage sensor creation; updates GPS creation on ESP32 to use configured UART/pins. |
| PowerControlHub/SensorConfigCommandHandler.h | Changes sensor config broadcast fields; updates remove command to S2:v=<idx> and adjusts semantics. |
| PowerControlHub/RelayController.h | Adds RelayResult::InvalidPin and validates relay pin assignments with PinGuard. |
| PowerControlHub/RelayCommandHandler.cpp | Returns Invalid pin for blocked relay pin assignments and emits debug reason. |
| PowerControlHub/PowerControlHubApp.cpp | Adds crash counter increment/reset flow and applies persisted PinGuard mode early in boot. |
| PowerControlHub/PowerControlHub.vcxproj.filters | Adds new headers to VS filters; removes some legacy entries. |
| PowerControlHub/PowerControlHub.ino | Removes manual GPS serial init and updates comments to reflect config-driven init. |
| PowerControlHub/PinGuard.h | Adds PinGuard implementation (pin tables, modes, validation, reason strings). |
| PowerControlHub/NextionConfigCommandHandler.h | Adds InvalidPin handling and debug output for Nextion pin setters. |
| PowerControlHub/MicroSdDriver.cpp | Adds PinGuard hard-block checks before SPI init to avoid crashes/hangs. |
| PowerControlHub/Local.h | Adds PinGuard-related explanatory comments. |
| PowerControlHub/ExternalSensorNetworkHandler.cpp | Updates external sensor remove semantics to v=<idx> and treats “already absent” as success. |
| PowerControlHub/ExternalSensorConfigCommandHandler.h | Updates external sensor remove semantics to v=<idx> and treats “already absent” as success. |
| PowerControlHub/ConfigNetworkHandler.cpp | Updates REST external sensor remove semantics to v=<idx> and treats “already absent” as success. |
| PowerControlHub/ConfigManager.h | Adds crash counter increment API and persisted PinGuard flags setter. |
| PowerControlHub/ConfigManager.cpp | Implements crash counter increment and persisted PinGuard flags setter. |
| PowerControlHub/ConfigController.h | Adds ConfigResult::InvalidPin. |
| PowerControlHub/ConfigController.cpp | Adds PinGuard validation to several pin setters (SPI/SD/RTC/RGB/Nextion/XpdzTone). |
| PowerControlHub/ConfigCommandHandler.cpp | Adds debug output and ACK ... Invalid pin mapping for ConfigResult::InvalidPin. |
| PowerControlHub/Config.h | Repurposes header byte at offset 13 as pinGuardFlags. |
| PowerControlHub/BoardConfig.h | Includes PinGuard from the framework board config layer. |
| PowerControlHub.sln | Updates some solution item paths (Docs/TestData). |
| Docs/PinGuard.md | Adds documentation for PinGuard tiers, board tables, crash-loop guard, and F14. |
| Docs/Commands.md | Documents F14, adds Voltage sensor type + setup, updates several sensor config semantics, adds S23. |
| .gitignore | Adds /LocalOnly ignore entry. |
Comments suppressed due to low confidence (1)
PowerControlHub.sln:19
- The solution items use a mix of
..\Docs\...andDocs\...paths (e.g. Commands.md vs the rest). Unless the solution is intentionally meant to be opened from a different directory, this inconsistency will cause some docs to be missing in Visual Studio. Consider making the docs paths consistent (all relative to the.slnlocation).
ProjectSection(SolutionItems) = preProject
..\Docs\BluetoothBle.md = ..\Docs\BluetoothBle.md
Docs\Commands.md = Docs\Commands.md
..\Docs\DateTime.md = ..\Docs\DateTime.md
..\Docs\LedManager.md = ..\Docs\LedManager.md
..\LICENSE = ..\LICENSE
..\Docs\Local.md = ..\Docs\Local.md
..\Docs\MessageBus.md = ..\Docs\MessageBus.md
Docs\pcbway.md = Docs\pcbway.md
..\Docs\RestApi.md = ..\Docs\RestApi.md
..\Docs\ScheduleEvents.md = ..\Docs\ScheduleEvents.md
..\Docs\Sensors.md = ..\Docs\Sensors.md
..\Docs\Warnings.md = ..\Docs\Warnings.md
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.