FastLED 3.9.15
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/channels/manager.h" // for DriverInfo
16#include "fl/stl/shared_ptr.h"
17#include "fl/stl/span.h"
18#include "fl/stl/unique_ptr.h"
19#include "fl/stl/vector.h"
20
21// Forward declarations
22namespace fl {
23class json;
24class Remote;
25class RxChannel;
26namespace net { namespace ble { struct TransportState; } }
27}
28
33
39 int pin_tx;
40 int pin_rx;
44 bool gpio_baseline_test_done = false; // Track whether GPIO baseline test has run in loop()
45 bool debug_enabled = false; // Runtime debug logging toggle (default: off)
46 bool net_server_active = false; // Network server autoresearch active
47 bool net_client_active = false; // Network client autoresearch active
48 bool ble_server_active = false; // BLE GATT server autoresearch active
49 bool deliberate_hang_requested = false; // Watchdog autoresearch hang trigger (#2731)
50};
51
56void printJsonRaw(const fl::json& json, const char* prefix = "REMOTE: ");
57
61void printStreamRaw(const char* messageType, const fl::json& data);
62
66public:
69
72
76
80 void tick(uint32_t current_millis);
81
83 fl::Remote* getRemote() { return mRemote.get(); }
84
88
92
93private:
94 fl::unique_ptr<fl::Remote> mRemote; // Serial Remote RPC system instance
95 fl::unique_ptr<fl::Remote> mBleRemote; // BLE Remote RPC system instance (created by startBle)
96 fl::net::ble::TransportState* mBleState = nullptr; // Opaque BLE state (heap-allocated by ble::createTransport, nullptr on stub platforms)
97 fl::shared_ptr<AutoResearchState> mState; // Shared autoresearch state
98 bool mPendingBleStop = false; // Deferred BLE teardown flag (set by stopBle RPC)
99
102
103 // Private helper functions for RPC implementation
107};
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.
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)
TestState state
fl::unique_ptr< fl::Remote > remote
Definition RpcClient.ino:43
fl::json stopBleRemote()
Stop BLE remote (destroys BLE Remote + GATT server)
fl::json runParallelTestImpl(const fl::json &args)
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
fl::unique_ptr< fl::Remote > mBleRemote
fl::shared_ptr< AutoResearchState > mState
fl::json findConnectedPinsImpl(const fl::json &args)
void registerFunctions(fl::shared_ptr< AutoResearchState > state)
Register all RPC functions with shared autoresearch state.
~AutoResearchRemoteControl()
Destructor.
fl::json startBleRemote()
Start BLE remote (creates BLE GATT server + second Remote instance)
void registerAllMethods(fl::Remote *remote)
Register all RPC methods on a given Remote instance.
fl::unique_ptr< fl::Remote > mRemote
JSON-RPC server with scheduling support.
Definition remote.h:40
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