MCPcopy Create free account
hub / github.com/FastLED/FastLED / registerFunctions

Method registerFunctions

examples/AutoResearch/AutoResearchRemote.cpp:1301–3612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1299AutoResearchRemoteControl::~AutoResearchRemoteControl() = default;
1300
1301void AutoResearchRemoteControl::registerFunctions(fl::shared_ptr<AutoResearchState> state) {
1302 // Store shared state
1303 mState = state;
1304
1305 // NOTE: All RPC callbacks use const fl::json& for efficient parameter passing.
1306 // The RPC system strips const/reference qualifiers and stores values in the tuple,
1307 // then passes them as references to the function. This avoids copies while
1308 // maintaining clean const-correct API.
1309
1310 // Register "status" function - device readiness check
1311 mRemote->bind("status", [this](const fl::json& args) -> fl::json {
1312 fl::json status = fl::json::object();
1313 status.set("ready", true);
1314 status.set("pinTx", static_cast<int64_t>(mState->pin_tx));
1315 status.set("pinRx", static_cast<int64_t>(mState->pin_rx));
1316 return status;
1317 });
1318
1319 // NOTE: getSchema is no longer needed - use built-in "rpc.discover" instead
1320 // The rpc.discover method is automatically available via Remote->Rpc and returns
1321 // the full OpenRPC schema. Our custom getSchema was causing stack overflow on ESP32-C6.
1322
1323 // Register "debugTest" function - test RPC argument passing
1324 mRemote->bind("debugTest", [](const fl::json& args) -> fl::json {
1325 fl::json response = fl::json::object();
1326 response.set("success", true);
1327 response.set("received", args);
1328 return response;
1329 });
1330
1331 // Register "deliberateHang" - force an infinite loop with interrupts
1332 // disabled to validate the unified Watchdog implementation (#2731).
1333 // The watchdog should fire within its configured timeout, reset the
1334 // device, and let the bootloader become reachable again.
1335 // Returns success BEFORE hanging so the caller sees the ACK; the hang
1336 // begins in the next iteration of the loop.
1337 mRemote->bind("deliberateHang", [this](const fl::json& args) -> fl::json {
1338 (void)args;
1339 FL_WARN("[deliberateHang] watchdog test: spinning forever in 200 ms");
1340 mState->deliberate_hang_requested = true;
1341 fl::json response = fl::json::object();
1342 response.set("success", true);
1343 response.set("message", "device will hang after RPC returns; watchdog should reset within configured timeout");
1344 return response;
1345 });
1346
1347 // Register "drivers" function - list available drivers
1348 mRemote->bind("drivers", [this](const fl::json& args) -> fl::json {
1349 fl::json drivers = fl::json::array();
1350 for (fl::size i = 0; i < mState->drivers_available.size(); i++) {
1351 fl::json driver = fl::json::object();
1352 driver.set("name", mState->drivers_available[i].name.c_str());
1353 driver.set("priority", static_cast<int64_t>(mState->drivers_available[i].priority));
1354 driver.set("enabled", mState->drivers_available[i].enabled);
1355 drivers.push_back(driver);
1356 }
1357 return drivers;
1358 });

Callers

nothing calls this directly

Calls 15

runSingleTestImplMethod · 0.95
runParallelTestImplMethod · 0.95
startBleRemoteMethod · 0.95
stopBleRemoteMethod · 0.95
createFunction · 0.85
EdgeTimeClass · 0.85
make4PhaseTimingFunction · 0.85
getTestsFunction · 0.85
runMultiplyBenchmarkFunction · 0.85
runPerlinBenchmarkFunction · 0.85
measureWave8ExpandFunction · 0.85
validateParlioStreamingFunction · 0.85

Tested by

no test coverage detected