Skip to content

Latest commit

 

History

History
101 lines (59 loc) · 3.26 KB

api.md

File metadata and controls

101 lines (59 loc) · 3.26 KB

API Reference

Required dependencies

Function adaptation macros

Use the macros described below to add remote access to regular functions.

1. Global Functions

VRPC_GLOBAL_FUNCTION(<returnType>, <functionName>[, <argTypes>])

Example:

int foo () {
  // [...]
}

void bar (String& s, bool b) {
  // [...]
}

VRPC_GLOBAL_FUNCTION(int, foo)
VRPC_GLOBAL_FUNCTION(void, bar, String&, bool)

class VrpcAgent

The agent allows existing code to be called from remote.

Summary

Members Descriptions
public inline VrpcAgent(int maxBytesPerMessage) Constructs an agent.
public template<>
inline void begin(T & netClient,const String & domain,const String & token)
Initializes the object using a client class for network transport.
public inline bool connected() Reports the current connectivity status.
public inline void connect() Connect the agent to the broker.
public inline void loop() This function will send and receive VRPC packets.

Members

public inline VrpcAgent(int maxBytesPerMessage)

Constructs an agent.

Parameter

  • maxBytesPerMessage [optional, default: 1024] Specifies the maximum size a single MQTT message may have

public template<typename T>
inline void begin(T& netClient, const String& domain, const String& token)

Initializes the object using a client class for network transport.

Parameter

  • netClient A client class following the interface as described here

  • domain [optional, default: "vrpc"] The domain under which the agent-provided code is reachable

  • token [optional, default: ""] Access token as generated by Heisenware GmbH, or MQTT password if own broker is used

  • broker [optional, default: "vrpc.io"] Address of the MQTT broker

  • username [optional] MQTT username (not needed when using the vrpc.io broker)


public inline bool connected()

Reports the current connectivity status.

Returns

true when connected, false otherwise


public inline void connect()

Connect the agent to the broker.

The function will try to connect forever. Inspect the serial monitor to see the connectivity progress.


public inline void loop()

Send and receive VRPC packets.

NOTE: This function should be called in every loop