Skip to content

v1.13.20 - Code Refactor: Protocol Split & Comment Cleanup (2025-12-11)

What Changed?

This release separates the main firmware into two protocol-specific implementations: main.cpp for legacy protocol and main_next.cpp for unified device response protocol. Removed outdated comments and configuration notes, resulting in cleaner, more maintainable code. Both protocols build independently with no symbol conflicts.


What's New

Main Feature: Protocol-Specific Main Implementations

What it does:

  • main.cpp (227 lines): Legacy protocol using text/binary commands and detection_buffer
  • main_next.cpp (210 lines): Unified protocol using CommandQueue and EventQueue
  • Each file is focused on a single protocol, eliminating nested #if ENABLE_DEVICE_RESPONSE conditionals

How to use it:

# Build legacy protocol (default)
task build                      # or task dev:build

# Build unified protocol
pio run -e esp32dev-next

Code example:

// Legacy vs Unified Protocol Loop
// main.cpp: Legacy protocol loop
void loop() {
  process_protocol_commands();  // Text or binary commands
  detection_buffer_send();      // Async event transmission
  detection_process();          // Cosmic ray detection
}

// main_next.cpp: Unified protocol loop
void loop() {
  CommandQueue::receive();      // JSON command reception
  CommandQueue::execute();      // Command execution
  EventQueue::flush();          // Async event transmission
  detection_process();          // Cosmic ray detection
}

Installation

Quick Start

# Get the release
git checkout v1.13.20

# Build
task build

# Upload
task upload

# Check it works
task monitor

What's Different from the Last Version?

✅ Added

  • src/main_next.cpp: New main implementation for unified device response protocol (ENABLE_DEVICE_RESPONSE=1)
  • build_src_filter configuration in platformio.ini for both esp32dev-dev and esp32dev-next environments

🔧 Changed

  • src/main.cpp: Refactored to legacy protocol only, removed all ENABLE_DEVICE_RESPONSE conditional branches
  • platformio.ini: Added environment-specific source file filtering to prevent symbol conflicts
  • All outdated refactoring notes and version tags removed from comments

✅ Improved

  • Code clarity: Each main file focuses on one protocol (no nested #if directives)
  • Maintainability: Reduced cognitive load when reading protocol-specific code
  • Compilation: Only relevant source files compiled for each target

Is It Safe to Upgrade?

Backward Compatible: Yes

  • No functional changes to detection or command processing
  • Default build target (esp32dev-dev) produces identical firmware behavior
  • Existing deployments unaffected; new build configuration is optional

Tests Passed

  • task build (esp32dev-dev): SUCCESS - 26.6% flash, 8.8% RAM
  • pio run -e esp32dev-next: SUCCESS - 27.2% flash, 35.6% RAM
  • ✅ Both targets link without symbol conflicts
  • ✅ Pre-commit hooks pass (trailing whitespace, YAML, JSON, merge conflicts)

Build Results

Environment Flash RAM Purpose
esp32dev-dev 26.6% (348KB) 8.8% (28.8KB) Legacy protocol (default)
esp32dev-next 27.2% (357KB) 35.6% (116KB) Unified protocol (next-gen)

Release Details

  • Date: 2025-12-11
  • Version: v1.13.20
  • Files Changed: 4 (main.cpp, main_next.cpp, platformio.ini, plus 1 other refactor commit)
  • Commits: 3 refactoring + build config

Next Steps

  • Continue developing unified protocol features (CommandParser, enhanced validation)
  • Deprecate legacy protocol after unified protocol reaches feature parity
  • Eventually make unified protocol the default in main.cpp
  • Consider consolidating both into a single main.cpp with runtime selection