ThingsBoard Client SDK 0.16.0
Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
Loading...
Searching...
No Matches
RPC_Callback.h
Go to the documentation of this file.
1#ifndef RPC_Callback_h
2#define RPC_Callback_h
3
4// Local includes.
5#include "Callback.h"
6#include "Constants.h"
7
8
12class RPC_Callback : public Callback<void, JsonVariantConst const &, JsonDocument &> {
13 public:
15 RPC_Callback() = default;
16
24#if THINGSBOARD_ENABLE_DYNAMIC
27 RPC_Callback(char const * method_name, function callback, size_t const & response_size = JSON_OBJECT_SIZE(DEFAULT_RPC_AMOUNT))
28#else
29 RPC_Callback(char const * method_name, function callback)
30#endif // THINGSBOARD_ENABLE_DYNAMIC
31 : Callback(callback)
32 , m_method_name(method_name)
33#if THINGSBOARD_ENABLE_DYNAMIC
34 , m_response_size(response_size)
35#endif // THINGSBOARD_ENABLE_DYNAMIC
36 {
37 // Nothing to do
38 }
39
40 ~RPC_Callback() override = default;
41
45 char const * Get_Name() const {
46 return m_method_name;
47 }
48
52 void Set_Name(char const * method_name) {
53 m_method_name = method_name;
54 }
55
56#if THINGSBOARD_ENABLE_DYNAMIC
59 size_t const & Get_Response_Size() const {
60 return m_response_size;
61 }
62
66 void Set_Response_Size(size_t const & response_size) {
67 m_response_size = response_size;
68 }
69#endif // THINGSBOARD_ENABLE_DYNAMIC
70
71 private:
72 char const *m_method_name = {}; // Method name
73#if THINGSBOARD_ENABLE_DYNAMIC
74 size_t m_response_size = {}; // Required size to contain the response
75#endif // THINGSBOARD_ENABLE_DYNAMIC
76};
77
78#endif // RPC_Callback_h
uint8_t constexpr DEFAULT_RPC_AMOUNT
Definition: Constants.h:18
General purpose safe callback wrapper. Expects either c-style or c++ style function pointer,...
Definition: Callback.h:30
std::function< void(argument_types... arguments)> function
Callback signature.
Definition: Callback.h:34
Callback()=default
Constructs empty callback, will result in never being called. Internals are simply default constructe...
Server-side RPC callback wrapper, contains the needed configuration settings to create the request th...
Definition: RPC_Callback.h:12
void Set_Name(char const *method_name)
Sets the name we expect to be sent with the server-side RPC request so that this method callback will...
Definition: RPC_Callback.h:52
RPC_Callback()=default
Constructs empty callback, will result in never being called. Internals are simply default constructe...
char const * Get_Name() const
Gets the name we expect to be sent with the server-side RPC request so that this method callback will...
Definition: RPC_Callback.h:45
RPC_Callback(char const *method_name, function callback)
Constructs callback that will be called upon server-side RPC request arrival with the given method na...
Definition: RPC_Callback.h:29
~RPC_Callback() override=default