Skip to content

refactor(examples): split AutoResearchRemote.cpp into 10 files all under 1K LOC (closes #3132) - #3187

Merged
zackees merged 1 commit into
masterfrom
feat/3132-autoresearch-remote-split
Jun 16, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3132-autoresearch-remote-split

Conversation

@zackees

@zackees zackees commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Decomposes 3,960-LOC monolith into Core shell + 9 sibling files, all under 1K LOC. Each bind*Methods() is a private member of AutoResearchRemoteControl defined in its own .cpp file. Lambdas keep [this] capture so private access remains natural.

File LOC
AutoResearchRemote.cpp (Core) 403
AutoResearchRemoteRunSingleTest.cpp 750
AutoResearchRemoteRunParallelTest.cpp 379
AutoResearchRemoteBasicMethods.cpp 157
AutoResearchRemoteFlexioMethods.cpp 572
AutoResearchRemoteGpioMethods.cpp 605
AutoResearchRemoteBenchmarkMethods.cpp 409
AutoResearchRemoteAsyncNetMethods.cpp 369
AutoResearchRemoteCoroutineMethods.cpp 504
AutoResearchRemotePerfMethods.cpp 286

All braces balanced (verified during extraction).

Build verification: bash compile wasm --examples AutoResearch — SUCCESS (library 34.84s, sketch 16.40s, link 3.52s, total 81.87s).

Closes #3132. Meta tracking issue: #3127.

Generated with Claude Code.

Summary by CodeRabbit

  • New Features
    • Added remote control support for GPIO configuration and connectivity testing
    • Introduced benchmarking capabilities for SIMD operations, Perlin noise, and encoding performance
    • Added network and asynchronous networking test endpoints
    • Introduced coroutine and promise testing functionality
    • Added FlexIO RX testing and validation capabilities
    • Expanded performance profiling tools for memory operations and wave computations
    • Enhanced single and parallel test execution with improved validation

…der 1K LOC (closes #3132)

Decomposes the 3,960-LOC monolith into a Core shell plus 9 sibling files,
all under 1K LOC. Each new file holds one logical piece of the RPC
machinery:

  - AutoResearchRemote.cpp (Core, 403 LOC): includes + outer helpers
    (printJsonRaw, printStreamRaw), findConnectedPinsImpl, ctor/dtor,
    registerFunctions() shell calling each bind*Methods(),
    tick(), registerAllMethods(), startBleRemote(), stopBleRemote()
  - AutoResearchRemoteRunSingleTest.cpp (750 LOC): anonymous-namespace
    helpers (expectedClocklessWireUs, maxLaneLeds, ScopedFastLedBrightness,
    measureTightTiming) + runSingleTestImpl
  - AutoResearchRemoteRunParallelTest.cpp (379 LOC): runParallelTestImpl
  - AutoResearchRemoteBasicMethods.cpp (157 LOC): status, debugTest,
    deliberateHang, drivers, runSingleTest, runParallelTest, ping,
    testNoSerial
  - AutoResearchRemoteFlexioMethods.cpp (572 LOC): flexioRxBenchmark,
    flexioObjectFledTest, flexioRxLoopbackPing
  - AutoResearchRemoteGpioMethods.cpp (605 LOC): setDebug,
    testGpioConnection, getPins, setTxPin, setRxPin, setPins,
    findConnectedPins, help
  - AutoResearchRemoteBenchmarkMethods.cpp (409 LOC): testSimd,
    testSimdBenchmark, animartrixPerlinBench, wave8ExpandBenchmark,
    parlioStreamValidate, parlioEncodeBenchmark
  - AutoResearchRemoteAsyncNetMethods.cpp (369 LOC): testAsync,
    startNetServer, startNetClient, runNetClientTest, runNetLoopback,
    stopNet, startOta, stopOta, startBle, stopBle, decodeFile, bleStatus
  - AutoResearchRemoteCoroutineMethods.cpp (504 LOC): testCoroutineBasic,
    Stop, Concurrent, Await, AwaitError, PromiseCallbacks,
    PromiseCatchCallback, ChainedAwait, All
  - AutoResearchRemotePerfMethods.cpp (286 LOC): perfProbeMemcpy,
    perfProbeNop, perfProbeRepeat, wave2dPerf

Split mechanism: each bind*Methods() is a private member of
AutoResearchRemoteControl, declared in AutoResearchRemote.h. Each
function body lives in its own .cpp file. The lambdas inside each bind
use [this] capture and access private members (mRemote, mState,
runSingleTestImpl, etc.) naturally — same access rules as before the
split. No public-API change; only file partitioning.

registerFunctions() is now a 7-line shell that calls each bind*Methods()
in order. RPC registration order is preserved.

Build verification: bash compile wasm --examples AutoResearch — SUCCESS
(library 34.84s, sketch 16.40s, link 3.52s, total 81.87s).

Closes #3132. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 16, 2026
@zackees
zackees merged commit ec94e4d into master Jun 16, 2026
5 of 6 checks passed
@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 91bd8e84-7215-40bb-ad6e-099ce690a1fe

📥 Commits

Reviewing files that changed from the base of the PR and between 7bf2581 and babccad.

📒 Files selected for processing (11)
  • examples/AutoResearch/AutoResearchRemote.cpp
  • examples/AutoResearch/AutoResearchRemote.h
  • examples/AutoResearch/AutoResearchRemoteAsyncNetMethods.cpp
  • examples/AutoResearch/AutoResearchRemoteBasicMethods.cpp
  • examples/AutoResearch/AutoResearchRemoteBenchmarkMethods.cpp
  • examples/AutoResearch/AutoResearchRemoteCoroutineMethods.cpp
  • examples/AutoResearch/AutoResearchRemoteFlexioMethods.cpp
  • examples/AutoResearch/AutoResearchRemoteGpioMethods.cpp
  • examples/AutoResearch/AutoResearchRemotePerfMethods.cpp
  • examples/AutoResearch/AutoResearchRemoteRunParallelTest.cpp
  • examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp

📝 Walkthrough

Walkthrough

Splits the AutoResearch RPC registration into nine new .cpp files. The header gains seven private bindXxxMethods() declarations. Each new file implements one binding group—basic, GPIO, benchmark, FlexIO, async/net, performance, coroutine—plus separate files for runSingleTestImpl and runParallelTestImpl, all guarded by FASTLED_AUTORESEARCH_LOW_MEMORY.

Changes

AutoResearchRemote RPC Method Split

Layer / File(s) Summary
Header: bind helper declarations
examples/AutoResearch/AutoResearchRemote.h
Adds seven private bindXxxMethods() declarations with a comment block documenting the intended per-file split and call order from registerFunctions().
Single and parallel test runner implementations
examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp, examples/AutoResearch/AutoResearchRemoteRunParallelTest.cpp
Adds runSingleTestImpl (with anonymous-namespace timing/LED helpers, driver/encoder resolution, per-lane TX/RX channel construction, tight-timing micro-benchmark, and heap-guarded failure serialization) and runParallelTestImpl (driver/lane validation, parallel channel setup, RX loopback validation, and JSON response construction).
Basic and GPIO RPC method bindings
examples/AutoResearch/AutoResearchRemoteBasicMethods.cpp, examples/AutoResearch/AutoResearchRemoteGpioMethods.cpp
bindBasicMethods registers status, debugTest, deliberateHang, drivers, ASYNC runSingleTest/runParallelTest wrappers, ping, and testNoSerial. bindGpioMethods registers setDebug, testGpioConnection, getPins, setTxPin, setRxPin (with RX channel recreation and rollback), setPins (with rollback), findConnectedPins, and a help endpoint enumerating all known RPCs.
Benchmark RPC method bindings
examples/AutoResearch/AutoResearchRemoteBenchmarkMethods.cpp
bindBenchmarkMethods registers testSimd, testSimdBenchmark, animartrixPerlinBench, wave8ExpandBenchmark, parlioStreamValidate (with extensive type/range/txPins consistency validation and per-iteration timing arrays), and parlioEncodeBenchmark (PSRAM-permutation metrics and per-frame μs estimates).
FlexIO RPC method bindings
examples/AutoResearch/AutoResearchRemoteFlexioMethods.cpp
bindFlexioMethods registers three Teensy-4-only handlers with platform fallbacks: flexioRxBenchmark (square-wave TX + FlexIO RX edge capture with integer period statistics), flexioObjectFledTest (WS2812B-V5 pattern TX → FlexIO edge decode → byte comparison), and flexioRxLoopbackPing (manual GPIO toggling + raw edge-duration readback).
Async, net, OTA, BLE, and media decode RPC bindings
examples/AutoResearch/AutoResearchRemoteAsyncNetMethods.cpp
bindAsyncNetMethods registers testAsync (two-draw show/wait timing for async detection), net RPCs (startNetServer/Client, runNetClientTest, runNetLoopback, stopNet), OTA RPCs, BLE RPCs, decodeFile (H264 decode from memory stream returning first 16 RGB pixels), and bleStatus.
Performance probe RPC bindings
examples/AutoResearch/AutoResearchRemotePerfMethods.cpp
bindPerfMethods registers perfProbeMemcpy (memcpy throughput with static 8 KB buffers), perfProbeNop (inline-asm NOP loop timing), perfProbeRepeat (wave repeat-stability measurement), and wave2dPerf (2D wave benchmark with optional loads-only path).
Coroutine RPC method bindings
examples/AutoResearch/AutoResearchRemoteCoroutineMethods.cpp
bindCoroutineMethods registers eight coroutine-test RPCs (basic completion, stop-while-running, concurrent, promise await/reject, then/catch callback dispatch with update() pumping, three-stage chained pipeline) and testCoroutineAll which sequences all individual tests and aggregates pass/fail.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#3118: Registers the same perfProbeMemcpy, perfProbeNop, and perfProbeRepeat RPC endpoints now implemented in AutoResearchRemotePerfMethods.cpp.
  • FastLED/FastLED#2766: Implements the hardware-layer RxBackend::FLEXIO channel with edge capture and decode() behavior consumed by bindFlexioMethods() in this PR.
  • FastLED/FastLED#3120: Introduces the fl::wave_perf::runWavePerfRepeat/runWavePerf helpers wired by bindPerfMethods() in this PR.

Poem

🐇 Hippity-hop, the big file did split,
Into seven neat pieces that perfectly fit!
bindBasicMethods, bindFlexio too,
Each rabbit has burrows — one RPC group per flue.
No more 4,017-line beast in one den,
Just tidy small warrens — compile fast again! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3132-autoresearch-remote-split

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees deleted the feat/3132-autoresearch-remote-split branch June 16, 2026 05:49
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 16, 2026
zackees added a commit that referenced this pull request Jun 16, 2026
…d*Methods (#3188)

Follow-up to #3187 (AutoResearchRemote.cpp split). Each bind*Methods()
now takes the fl::Remote* target as a parameter rather than implicitly
using mRemote. Makes the dependency obvious from the signature and lets
the same partitioning serve mBleRemote or any future transport without
duplicating code.

Before:
  void bindBasicMethods();             // implicit this->mRemote
  void registerFunctions(state) {
      mState = state;
      bindBasicMethods();
      bindFlexioMethods();
      ...
  }

After:
  void bindBasicMethods(fl::Remote* remote);
  void registerFunctions(state) {
      mState = state;
      bindBasicMethods(mRemote.get());
      bindFlexioMethods(mRemote.get());
      ...
  }

Mechanical sweep across 7 binder .cpp files: 50 mRemote->bind sites
rewritten to remote->bind; signatures updated; registerFunctions shell
in AutoResearchRemote.cpp updated to pass mRemote.get() to each call.

Verified: bash compile wasm --examples AutoResearch — success (library
32.53 s, sketch 2.37 s, link 4.86 s, total 48.42 s).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 16, 2026
…ey test (#3191)

Follow-up to #3187/#3188/#3189. Old names were partly implementation-named
(FlexIO is Teensy-only), partly vague (Basic, Coroutine). Renaming so each
group describes WHAT the RPCs exercise.

Rename map:
  bindBasicMethods     → bindSystemMethods      // status, ping, debug, help
  bindFlexioMethods    → bindDriverMethods      // LED driver tests (FlexIO today)
  bindGpioMethods      → bindPinMethods         // pin config (GPIO is impl)
  bindBenchmarkMethods → bindMathMethods        // SIMD/animartrix/wave/parlio
  bindAsyncNetMethods  → bindNetworkMethods     // WiFi/OTA/BLE/codec/testAsync
  bindCoroutineMethods → bindAsyncMethods       // coroutine + promise primitives
  bindPerfMethods      → bindBenchmarkMethods   // perfProbe* + wave2dPerf

Files renamed (git mv preserves history):
  BasicMethods.cpp     → SystemMethods.cpp
  FlexioMethods.cpp    → DriverMethods.cpp
  GpioMethods.cpp      → PinMethods.cpp
  BenchmarkMethods.cpp → MathMethods.cpp
  AsyncNetMethods.cpp  → NetworkMethods.cpp
  CoroutineMethods.cpp → AsyncMethods.cpp
  PerfMethods.cpp      → BenchmarkMethods.cpp  (swap: was PerfMethods, takes
                                                BenchmarkMethods name now)

Header file-comments rewritten to describe the *category* rather than
enumerate every RPC — categories are stable, RPC lists drift.

Driver bin's comment notes the platform-specificity intent: today it
holds Teensy 4.x FlexIO RX validation; future platform-specific driver
tests for other MCUs land in the same bin, gated by per-binding #if
guards rather than file-level partitioning.

Verified: bash compile wasm --examples AutoResearch — success
(library 40.03 s, sketch 2.89 s, link 6.05 s, total 59.89 s).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Split examples/AutoResearch/AutoResearchRemote.cpp (4,017 LOC) into 7 files of <1K LOC each (sub-issue of #3127)

1 participant