Stepdance Software Library
Loading...
Searching...
No Matches
RPC Class Reference

RPC class for handling remote procedure calls over serial streams. More...

#include <rpc.hpp>

Inheritance diagram for RPC:

Public Member Functions

void begin ()
 Initializes the RPC with the specified stream. Defaults to Serial if no stream is provided.
void begin (Stream *target_stream)
 Initializes the RPC with the specified stream.
void begin (usb_serial_class *target_usb_serial)
 Initializes the RPC with the specified USB serial class.
void begin (HardwareSerialIMXRT *target_serial, uint32_t baud, uint16_t format=0)
 Initializes the RPC with the specified hardware serial.
template<typename Ret, typename... Args>
void enroll (const String &name, Ret(*func)(Args...))
template<typename Obj, typename Ret, typename... Args>
void enroll (const String &instance_name, const String &name, Obj &instance, Ret(Obj::*method)(Args...))
void enroll (const String &name, Plugin &instance)
template<typename T, typename = std::enable_if_t<!std::is_base_of_v<Plugin, T>>>
void enroll (const String &name, T &parameter)
template<typename... Args, size_t... I>
void call_and_respond (void(*func)(Args...), JsonArray args, std::index_sequence< I... >)
template<typename Obj, typename... Args, size_t... I>
void call_and_respond (Obj &instance, void(Obj::*method)(Args...), JsonArray args, std::index_sequence< I... >)
template<typename Ret, typename... Args, size_t... I>
void call_and_respond (Ret(*func)(Args...), JsonArray args, std::index_sequence< I... >)
template<typename Obj, typename Ret, typename... Args, size_t... I>
void call_and_respond (Obj &instance, Ret(Obj::*method)(Args...), JsonArray args, std::index_sequence< I... >)

Protected Member Functions

void loop ()

Detailed Description

RPC class for handling remote procedure calls over serial streams.

The RPC class provides an interface for registering functions and parameters that can be called and accessed remotely via over serial streams. It supports enrolling functions with various signatures, as well as plugin instances and parameters. The class handles dispatching incoming RPC calls and sending responses back to the caller. Here's an example of how to instantiate and configure an RPC:
RPC Example.

Member Function Documentation

◆ begin() [1/3]

void RPC::begin ( HardwareSerialIMXRT * target_serial,
uint32_t baud,
uint16_t format = 0 )

Initializes the RPC with the specified hardware serial.

Parameters
target_serialPointer to the HardwareSerialIMXRT to use for RPC communication.
baudBaud rate for the serial communication.
formatData format for the serial communication.

◆ begin() [2/3]

void RPC::begin ( Stream * target_stream)

Initializes the RPC with the specified stream.

Parameters
target_streamPointer to the Stream to use for RPC communication.

◆ begin() [3/3]

void RPC::begin ( usb_serial_class * target_usb_serial)

Initializes the RPC with the specified USB serial class.

Parameters
target_usb_serialPointer to the usb_serial_class to use for RPC communication.

The documentation for this class was generated from the following file: