v1.4.0 - Major Refactoring - Technical Debt Reduction #27
francescopace
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🏗️ Major Refactoring - Technical Debt Reduction
Comprehensive code reorganization to improve maintainability, reduce duplication, and enforce separation of concerns
This release focuses on addressing technical debt accumulated during rapid feature development. The refactoring was driven by insights gained from the MicroPython implementation (Micro-ESPectre), which enabled faster parameter tuning and testing of optimal configurations. The lessons learned were then applied to improve the C firmware architecture.
Key Objectives:
🏗️ Modular Architecture Improvements
Code reorganization for better separation of concerns
Feature Extraction Module (
csi_features.c/h):csi_processorinto dedicated modulecsi_processor.cfrom ~800 to ~400 lines (-50%)csi_extract_features()orchestrator incsi_processor.ccsi_get_subcarrier_selection(),csi_processor_get_turbulence_buffer()MQTT Publisher Task:
mqtt_publish_task→mqtt_publisherfor clarityespectre.ctomqtt_handler.cformat_progress_barhelper function tomqtt_handler.cmqtt_publisher_context_tstructure for task parametersmqtt_start_publisher()API to start publisher taskSegmentation Logic Consolidation:
csi_processormodulesegmentation.c/hfilescsi_processorhandles all CSI processingBenefits:
🔧 Configuration Centralization
Single source of truth for all system defaults
Centralized Configuration in
espectre.h:#defineacross 9 files with centralized constantsValidation Centralization (
validation.h/c):Python/C Synchronization:
Benefits:
🔬 Improved Algorithms & Testing
Numerically stable variance calculation and stricter test validation
Two-Pass Variance Algorithm:
calculate_variance_two_pass()for numerically stable variance calculation7_analyze_variance_algo.pyfor algorithm comparisonEnhanced Test Suite:
esp_heap_caps.h→esp_system.hforesp_get_free_heap_size()Test Results:
Documentation:
PERFORMANCE.mdto document performance metrics and test resultsBenefits:
✨ Enhanced Features
Extended MQTT info command with device and network diagnostics
Extended
infocommand with detailed device and network information:Device Information:
Network Information:
Implementation:
🗑️ Code Cleanup
Removed obsolete functionality and simplified workflows
CSI Raw Data Extractor Removal:
data_collector.pyscript in micro-espectreRemoved Components:
mqtt_commands.c:csi_raw_capturecommand, capture functions and structuresmqtt_commands.h:mqtt_commands_capture_csi_packet()declarationespectre.c:mqtt_commands_capture_csi_packet()call incsi_callbackBenefits:
📊 Impact Summary
Overall improvements from this refactoring release:
Lines of Code:
csi_processor.c: ~800 → ~400 lines (-50%)MicroPython Contribution:
The MicroPython implementation (Micro-ESPectre) proved invaluable for rapid prototyping and parameter tuning. The ability to quickly test configurations and algorithms in Python accelerated the optimization process, with successful patterns then being ported back to the C firmware with confidence.
🚀 Enhanced - Traffic Generator Rate Limit
Increased maximum rate from 50 to 1000 pps for high-frequency motion detection:
🔧 Changed - Feature Extraction Always Active
Modified feature extraction behavior to be always active when enabled, regardless of segmentation state:
Previous behavior:
New behavior:
features_enabled=trueBenefits:
🔄 Migrated - ESPectre CLI to Python
Rewrote CLI from Bash to Python for cross-platform support:
paho-mqttinstead of externalmosquitto_pub/sub🎵 Added - Wi-Fi Theremin Sonification
Real-time audio sonification of CSI data via
espectre-theremin.html:🗑️ Removed - Redundant Segmentation Parameters
Simplified segmentation: Removed redundant min_length, max_length, k_factor parameter
After analysis of the segmentation algorithm, removed the
min_lengthparameter as it was redundant with the moving variance window:Removed redundant
k_factormultiplier - users can now adjust threshold directly.Removed
min_segment_lengthparameter to simplify segmentation configuration:Removed
max_segment_lengthparameter to simplify segmentation configuration:This discussion was created from the release v1.4.0 - Major Refactoring - Technical Debt Reduction.
Beta Was this translation helpful? Give feedback.
All reactions