Skip to content

Commit d75dda7

Browse files
committed
Refactor core layer to eliminate platform dependencies and improve testability
1 parent 27c40b3 commit d75dda7

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

docs/architecture-refactoring.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Architecture Refactoring: Clean Core Layer
22

3-
**Date**: 2025-01-XX
3+
**Date**: 2025-11-01 (Completed)
44
**Goal**: Eliminate platform dependencies from `core/` modules using dependency injection and command pattern.
55

66
---
@@ -243,12 +243,25 @@ For existing modules that need HAL:
243243

244244
## Summary
245245

246-
**Before**: 4 files in `core/` had platform dependencies
246+
**Before**: 6 files in `core/` had platform dependencies
247+
- `ground_safety.cpp` - Arduino.h, millis()
248+
- `arm_calibration.cpp` - Arduino.h, imu.h, nvs_cal.h, millis(), micros()
249+
- `mixer_table.cpp` - platform/arduino/assert.h
250+
- `safety.cpp` - Arduino.h, millis()
251+
- `imu_mapping.cpp` - platform/arduino/assert.h
252+
- `accel_cal_validation.cpp` - wrong namespace for isfinite/fabs
253+
247254
**After**: 100% platform-independent (except logger utility)
248255

256+
**Additional Fixes**:
257+
- Renamed `platform/arduino/assert.h``runtime_assert.h` (avoid system header conflict)
258+
- Fixed include paths in platform files (nvs_cal.cpp, radio.cpp, telemetry.cpp)
259+
- Added missing config.h includes (rc_packet.cpp, input_processor.cpp, test files)
260+
249261
**Key Techniques**:
250-
- Dependency Injection (timing)
251-
- Command Pattern (HAL operations)
262+
- Dependency Injection (timing via parameters)
263+
- Command Pattern (HAL operations return commands)
252264
- Clean interfaces (no leaky abstractions)
253265

254266
**Result**: Core business logic is now fully testable, portable, and maintainable.
267+
**Build Status**: ✅ All tests pass, ESP32 builds successfully

0 commit comments

Comments
 (0)