v1.17.5 - Dead Code Cleanup (2025-12-15)¶
What Changed?¶
This release removes accumulated dead code and unused API declarations from the v2 device response protocol infrastructure. The cleanup improves code maintainability and reduces binary size without any functional changes. All three build profiles (v1, v2, WiFi) continue to work identically.
What's New¶
Main Feature: Dead Code Removal & Refactoring¶
What it does:
- Removes unused
DeviceResponseBuilderclass that was compiled but never called - Removes unused
device_response_send()function that was defined but never invoked - Removes unused function declarations from Command manager that had no implementations
- Removes unused
Command::format_status()method that was never called by any handler
Impact:
- Code is cleaner and easier to maintain
- Binary size reduced by ~500-600 bytes
- No changes to functionality or user-visible behavior
- All existing tests continue to pass
Installation¶
Quick Start¶
# Get the release
git checkout v1.17.5
# Build
task build
# Upload
task upload
# Check it works
task monitor
What's Different from the Last Version?¶
✅ Removed¶
- DeviceResponseBuilder class (
v2_device_response_builder.h/cpp) - Was compiled in v2 environment but never used
-
Removed declarations and implementations
-
device_response_send() function (
v2_device_response_send.h/cpp) - Was declared but never called anywhere in codebase
-
Response serialization is handled directly in
v2_device_response.cpp::send() -
Unused Command manager functions (
v2_command_manager.h) error_response()- declared but never implemented (0 calls)success_response()- declared but never implemented (0 calls)success_response_string()- declared but never implemented (0 calls)-
Replaced by inline functions in v2_command_queue.h
-
Command::format_status() method (
v2_command.h/cpp) - Method declared but never called from any handler
- GET_STATUS command builds structured JsonDocument directly instead
🔧 Changed¶
- v2_command_manager.h: Updated documentation to remove references to deleted functions
- v2_command.h: Removed "Utility Methods" section
- v2_command.cpp: Cleaned up obsolete documentation comments
📊 Code Quality Metrics¶
- Files removed: 4 (2 headers, 2 implementations)
- Lines of code removed: 435+
- Binary size reduction: ~500-600 bytes
- Build time: Unchanged
- RAM usage: Unchanged
- Flash usage: Unchanged
Is It Safe to Upgrade?¶
Backward Compatible: Yes
- All three build profiles work identically to v1.17.4
- No changes to command protocols or responses
- No changes to detection or sensor functionality
- No changes to hardware interfaces
- Pure refactoring with zero behavioral impact
Tests Passed¶
- ✅ v1 environment builds without errors (esp32dev-release)
- ✅ v2 environment builds without errors (esp32dev-next)
- ✅ WiFi environment builds without errors (esp32dev-wifi)
- ✅ All commits pass pre-commit hooks (trailing whitespace, file endings, merge conflicts)
- ✅ No compilation warnings introduced
- ✅ Binary sizes remain within limits
Release Details¶
- Date: 2025-12-15
- Version: v1.17.5
- Files Changed: 4 files removed, 3 files modified
- Commits: 3
refactor(v2): remove unused DeviceResponseBuilder classrefactor(v2): remove unused device_response_send functionrefactor(v2): remove unused functions and methods from Command infrastructure
Development Notes¶
Dead Code Analysis¶
The cleanup was informed by a comprehensive code analysis that identified:
- v2_device_response_builder.cpp - Unused in both v1 and v2 environments
- v1: Excluded via build_src_filter
-
v2: Included but never called
-
v2_device_response_send.cpp - Unused function definition
- Serialization handled by v2_device_response.cpp::send()
-
No callers in entire codebase
-
v2_command_manager.h - Broken API contract
- Three functions declared but never implemented
- Would cause link errors if called
-
Replaced by Phase 6 inline helpers
-
Command::format_status() - Obsolete method
- Replaced by structured JsonDocument approach in handlers
- Zero calls from any code path
Design Pattern Evolution¶
The removal reflects the evolution of the v2 device response protocol:
- Phase 0.5 (Legacy): Used
DeviceResponseBuilder::simple()and string formatting - Phase 6 (Current): Uses inline
command_response_ok/error()with JsonDocument payload pointers - Result: Cleaner, more type-safe, zero-overhead pattern
Next Steps¶
Future cleanup opportunities:
- Continue dead code removal in v1 legacy protocol modules
- Evaluate consolidation of builder patterns across codebase
- Review additional unused methods in singleton classes