FastLED 3.10.8
Loading...
Searching...
No Matches
AutoResearchRemote.h
Go to the documentation of this file.
1// examples/AutoResearch/AutoResearchRemote.h
2//
3// Remote RPC control system for AutoResearch sketch.
4// Provides JSON-RPC interface for dynamic test control via serial commands.
5//
6// ARCHITECTURE:
7// - All test output is communicated EXCLUSIVELY via JSON-RPC
8// - ScopedLogDisable suppresses FL_DBG/FL_PRINT during test execution
9// - RPC responses use printJsonRaw() which bypasses fl::println (direct Serial output)
10// - This allows clean, parseable JSON output without debug noise
11
12#pragma once
13
14#include "fl/stl/stdint.h" // for uint32_t, uint8_t
15#include "fl/remote/remote.h" // for fl::Remote (no longer provided by FastLED.h)
16#include "fl/channels/manager.h" // for DriverInfo
17#include "fl/stl/shared_ptr.h"
18#include "fl/stl/span.h"
19#include "fl/stl/unique_ptr.h"
20#include "fl/stl/vector.h"
21
22// Forward declarations
23namespace fl {
24class json;
25class Remote;
26class RxChannel;
27namespace net { namespace ble { struct TransportState; } }
28}
29
34
40 int pin_tx;
41 int pin_rx;
45 bool gpio_baseline_test_done = false; // Track whether GPIO baseline test has run in loop()
46 bool led_rx_available = false; // True only after the configured RX path validates
47 bool debug_enabled = false; // Runtime debug logging toggle (default: off)
48 bool net_server_active = false; // Network server autoresearch active
49 bool net_client_active = false; // Network client autoresearch active
50 bool ble_server_active = false; // BLE GATT server autoresearch active
51 bool deliberate_hang_requested = false; // Watchdog autoresearch hang trigger (#2731)
52
57};
58
63void printJsonRaw(const fl::json& json, const char* prefix = "REMOTE: ");
64
68void printStreamRaw(const char* messageType, const fl::json& data);
69
73public:
76
79
83
87 void tick(uint32_t current_millis);
88
90 fl::Remote* getRemote() { return mRemote.get(); }
91
95
99
100private:
101 fl::unique_ptr<fl::Remote> mRemote; // Serial Remote RPC system instance
102 fl::unique_ptr<fl::Remote> mBleRemote; // BLE Remote RPC system instance (created by startBle)
103 fl::net::ble::TransportState* mBleState = nullptr; // Opaque BLE state (heap-allocated by ble::createTransport, nullptr on stub platforms)
104 fl::shared_ptr<AutoResearchState> mState; // Shared autoresearch state
105 bool mPendingBleStop = false; // Deferred BLE teardown flag (set by stopBle RPC)
106
109
110 // Private helper functions for RPC implementation
114
115 // RPC binding helpers — each implemented in its own .cpp file to keep
116 // file sizes below 1 K LOC (#3132 / meta #3127). The Remote target is
117 // passed explicitly so the same partitioning can be used for the BLE
118 // Remote (mBleRemote) or any future transport.
127};
void printStreamRaw(const char *messageType, const fl::json &data)
Print JSONL stream message directly to Serial, bypassing fl::println.
void printJsonRaw(const fl::json &json, const char *prefix="REMOTE: ")
Print JSON directly to Serial, bypassing fl::println and ScopedLogDisable This ensures RPC responses ...
fl::shared_ptr< fl::RxChannel >(*)(int pin) RxDeviceFactory
Factory function type for creating RxChannel instances.
TestState state
fl::unique_ptr< fl::Remote > remote
Definition RpcClient.ino:43
void bindNetworkMethods(fl::Remote &remote)
void bindRpSpiMethods(fl::Remote &remote)
fl::json stopBleRemote()
Stop BLE remote (destroys BLE Remote + GATT server)
fl::json runParallelTestImpl(const fl::json &args)
AutoResearchRemoteControl()
Constructor.
void tick(uint32_t current_millis)
Process RPC system (pull + tick + push)
fl::Remote * getRemote()
Get underlying Remote instance.
fl::json runSingleTestImpl(const fl::json &args)
fl::net::ble::TransportState * mBleState
void bindBenchmarkMethods(fl::Remote &remote)
fl::unique_ptr< fl::Remote > mBleRemote
void bindSystemMethods(fl::Remote &remote)
fl::shared_ptr< AutoResearchState > mState
fl::json findConnectedPinsImpl(const fl::json &args)
void bindDriverMethods(fl::Remote &remote)
void registerFunctions(fl::shared_ptr< AutoResearchState > state)
Register all RPC functions with shared autoresearch state.
~AutoResearchRemoteControl()
Destructor.
void bindPinMethods(fl::Remote &remote)
fl::json startBleRemote()
Start BLE remote (creates BLE GATT server + second Remote instance)
void bindAsyncMethods(fl::Remote &remote)
void registerAllMethods(fl::Remote *remote)
Register all RPC methods on a given Remote instance.
fl::unique_ptr< fl::Remote > mRemote
void bindMathMethods(fl::Remote &remote)
JSON-RPC server with scheduling support.
Definition remote.h:42
Unified manager for channel drivers with priority-based fallback.
Base definition for an LED controller.
Definition crgb.hpp:179
corkscrew_args args
Definition old.h:149
fl::u32 uint32_t
Definition stdint.h:218
fl::shared_ptr< fl::RxChannel > rx_channel
fl::span< uint8_t > rx_buffer
fl::vector< fl::DriverInfo > drivers_available
RxDeviceFactory rx_factory
AutoResearch runtime state (shared between main loop and RPC handlers)