Skip to content

v1.8.9 - Binary Command Module Refactoring (2025-11-24)

What Changed?

This release consolidates the binary protocol layer into a single, self-contained binary_command module. The refactoring improves code organization and modularity by combining previously separated concerns (protocol reception, command handling, validation) into one logical unit. No functional changes; purely architectural improvement.


What's New

Architecture Improvement: Unified Binary Command Module

What it does: Consolidates binary_protocol.h/cpp and binary_protocol_handler.h/cpp into a single binary_command.h/cpp module with clear responsibility separation through 8 organized sections.

Module Organization:

  • Section 1: Configuration constants (queue size, timeout)
  • Section 2: Type definitions (binary_command_t)
  • Section 3: Initialization (binary_command_init())
  • Section 4: Reception & availability (binary_available(), binary_receive_line())
  • Section 5: Queue management (binary_queue(), binary_queued(), binary_dequeue())
  • Section 6: Flow control (binary_receive(), binary_execute())
  • Section 7: Validation & execution (binary_validate())
  • Section 8: Response generation (binary_response_ok(), binary_response_error())

How to use it:

No API changes. Existing usage remains identical:

// In main loop:
binary_receive();   // Read and queue incoming commands
binary_execute();   // Process queued commands

Code example:

// binary_command.h header organization
#include <Arduino.h>
#include "config.h"

// Section 1: Constants
#define BINARY_COMMAND_QUEUE_SIZE 10
#define BINARY_COMMAND_TIMEOUT_MS 500

// Section 2: Types
typedef struct {
  uint8_t channel;
  uint8_t data1;
  uint8_t data2;
} binary_command_t;

// Section 3-8: Function declarations organized by responsibility
bool binary_available(void);
bool binary_receive_line(int &channel, byte &data1, byte &data2);
// ... etc

Installation

Quick Start

# Get the release
git checkout v1.8.9

# Build
task build

# Upload
task upload

# Check it works
task monitor

What's Different from the Last Version?

✅ Added

  • Clear 8-section organization in binary_command.h for improved readability
  • Self-contained binary_discard() utility in binary_command.cpp (removed external dependency)

🔧 Changed

  • File structure:
  • binary_protocol.h + binary_protocol_handler.hbinary_command.h
  • binary_protocol.cpp + binary_protocol_handler.cppbinary_command.cpp
  • Naming: Layer references updated from "binary protocol" to "binary command"
  • Dependencies: Removed serial_protocol.h dependency from binary_command.cpp
  • Header includes: serial_protocol.h now references binary_command.h instead of binary_protocol.h

🐛 Fixed

  • None (architectural refactoring only)

Is It Safe to Upgrade?

Backward Compatible: Yes ✅

  • All function signatures remain unchanged
  • All functionality preserved (1:1 feature parity)
  • No behavioral changes; purely structural reorganization
  • Memory usage identical (7.3% RAM, 24.0% Flash)
  • Existing binary protocol commands work without modification

Tests Passed

  • ✅ Development build (task dev:build) - Success
  • ✅ Production build (task prod:build) - Success
  • ✅ Memory usage within limits (7.3% RAM, 24.0% Flash)
  • ✅ No compiler errors or undefined symbol errors
  • ✅ All binary command functions verified

Architecture Improvements

Before (4 files, 450 lines)

include/
  ├── binary_protocol.h (123 lines)
  └── binary_protocol_handler.h (59 lines)

src/
  ├── binary_protocol.cpp (182 lines)
  └── binary_protocol_handler.cpp (86 lines)

After (2 files, 296 lines)

include/
  └── binary_command.h (173 lines)

src/
  └── binary_command.cpp (267 lines)

Benefits:

  • ✅ File count reduced: 4 → 2
  • ✅ Type definitions co-located with usage
  • ✅ Related functions grouped by responsibility
  • ✅ Reduced header dependency chain
  • ✅ Self-contained module (no serial_protocol.h dependency)

Release Details

  • Date: 2025-11-24
  • Version: v1.8.9
  • Type: Architectural refactoring (no feature changes)
  • Files Changed: 6 (created 2, modified 1, deleted 3)
  • Commits:
  • 78ea917 - refactor(binary-command): consolidate protocol layers into single binary_command module
  • cca1033 - refactor(binary-command): remove serial_protocol.h dependency

Next Steps

  • Monitor production deployments for stability
  • Consider applying same consolidation pattern to text_command if handlers grow significantly
  • Evaluate other protocol layers for similar optimization opportunities