Setup async task for JSON-RPC processing.
- Parameters
-
| remote_control | Reference to RemoteControl singleton |
| interval_ms | Task interval in milliseconds (default: 10ms) |
- Returns
- Task handle (auto-registered with scheduler)
This function creates an async task that polls the RPC system at regular intervals, allowing RPC commands to be processed without blocking the main loop.
The 10ms default interval balances:
- Responsiveness: 115200 baud ≈ 100 bytes in 10ms
- CPU overhead: Minimal impact on LED peripheral operations
The task is automatically registered with the scheduler via .then() and will run until the program exits.
THREAD SAFETY:
- Safe to capture remote_control by reference (singleton lifetime)
- ESP32 Arduino runs on single core - task switching is atomic
- No additional synchronization needed
Definition at line 43 of file AutoResearchAsync.h.
43 {
45 .
then([&remote_control]() {
46 uint32_t current_time = millis();
47 remote_control.
tick(current_time);
48 });
49}
void tick(uint32_t current_millis)
Process RPC system (pull + tick + push)
Handle & then(function< void()> on_then) FL_NO_EXCEPT
Sets the callback invoked when the task runs successfully.
Handle every_ms(int interval_ms) FL_NO_EXCEPT
Creates a task that runs at a fixed millisecond interval.
#define FL_TRACE
A macro to capture the current source file, line number, and time.
References fl::task::every_ms(), FL_TRACE, fl::task::Handle::then(), and AutoResearchRemoteControl::tick().