In this repo it will be implemented an Arduino library wrapper for RPClite to be run on Arduino UNO Q boards.
Including Arduino_RouterBridge.h gives the user access to a Bridge object that can be used both as a RPC client and/or server to execute and serve RPCs to/from the CPU Host running a GOLANG router.
#include<Arduino_RouterBridge.h>boolset_led(bool state) {digitalWrite(LED_BUILTIN, state);return state;}Stringgreet() {returnString("Hello Friend");}voidsetup() { Bridge.begin(); Monitor.begin();pinMode(LED_BUILTIN, OUTPUT);if (!Bridge.provide("set_led", set_led)) { Monitor.println("Error providing method: set_led"); }else { Monitor.println("Registered method: set_led"); } Bridge.provide_safe("greet", greet);}voidloop() {float sum;// CALL EXAMPLES// Standard chained call: Bridge.call("method", params...).result(res)if (!Bridge.call("add",1.0,2.0).result(sum)) { Monitor.println("Error calling method: add"); };// Async call RpcResult async_rpc = Bridge.call("add",3.0,4.5);if (!async_rpc.result(sum)) { Monitor.println("Error calling method: add"); Monitor.print("Error code:"); Monitor.println(async_rpc.error.code); Monitor.print("Error message:"); Monitor.println(async_rpc.error.traceback); }// Implicit boolean cast. Use with caution as in this case the call is indeed// executed expecting a fallback nil result (MsgPack::object::nil_t)if (!Bridge.call("send_greeting","Hello Friend")) { Monitor.println("Error calling method: send_greeting"); };// Please use notify when no reult (None, null, void, nil etc.) is expected from the opposite side// the following is executed immediately Bridge.notify("signal",200);}