Feat: Implement enhanced logging and config validation (Phase 1)#3
Open
leontappe wants to merge 2 commits into
Open
Feat: Implement enhanced logging and config validation (Phase 1)#3leontappe wants to merge 2 commits into
leontappe wants to merge 2 commits into
Conversation
This commit introduces Phase 1 of robustness improvements:
1. **Enhanced Logging for State Management:**
* Added logs for state enable/disable actions (`OBDState::setEnabled`).
* Added logs for changes to state update intervals (`OBDState::setUpdateInterval`).
* Added logs when `lastUpdate` timestamps are set (`TypedOBDState::readValue`, `TypedOBDState::calcValue`).
* Added detailed, conditional (via `DEBUG_STATE_FILTERING` macro) logging in `OBDStates::nextState` to show reasons for state filtering.
2. **Configuration Validation for `states.json`:**
* Added `OBDClass::validateStates()` method, called after states are loaded.
* Logs INFO for very short update intervals.
* Logs WARNING for enabled CALC states without calculation expressions.
3. **Basic Configuration Validation for `settings.json`:**
* Added `SettingsClass::validateSettings()` method, called after settings load/parse.
* Validates and logs INFO/WARNINGs for general, WiFi, and OBD2 settings (e.g., sleep duration, empty AP SSID, OBD2 adapter name/MAC, protocol character validity).
This commit introduces Phase 2 of robustness improvements:
1. **Improved Error Reporting in `OBDState::readValue()`:**
* Added `consecutiveReadFailures` member to `OBDState`.
* Implemented `getRxStateString` for readable ELM status logging.
* `TypedOBDState<T>::readValue()` now:
* Resets `consecutiveReadFailures` on success/no_data.
* Increments failure count and logs detailed errors (status string, raw status, count) on read failures.
* Auto-disables states via `setEnabled(false)` after `MAX_CONSECUTIVE_READ_FAILURES` (5) are reached.
* Avoids updating `lastUpdate` on errors.
2. **Enhanced PID Support Check Logic:**
* Corrected `supported` and `init` flag logic in `TypedOBDState<T>::readValue()` for accurate one-time PID support checking when `checkPidSupport` is enabled.
* Logs results of PID support checks (supported, not supported, or check failed).
* If a support check fails, PID is assumed supported to allow data queries, but failure is logged.
* `readValue` now returns early if a PID is definitively known as unsupported, preventing data queries.
* Updated `OBDStates::nextState()` predicate to correctly filter out `READ` states where `isSupported()` is false.
* Improved `DEBUG_STATE_FILTERING` logs for unsupported states.
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.
This commit introduces Phase 1 of robustness improvements:
Enhanced Logging for State Management:
OBDState::setEnabled).OBDState::setUpdateInterval).lastUpdatetimestamps are set (TypedOBDState::readValue,TypedOBDState::calcValue).DEBUG_STATE_FILTERINGmacro) logging inOBDStates::nextStateto show reasons for state filtering.Configuration Validation for
states.json:OBDClass::validateStates()method, called after states are loaded.Basic Configuration Validation for
settings.json:SettingsClass::validateSettings()method, called after settings load/parse.