Client-side RPC callback wrapper, contains the needed configuration settings to create the request that should be sent to the server. Documentation about the specific use of client-side RPC in ThingsBoard can be found here https://thingsboard.io/docs/user-guide/rpc/#client-side-rpc.
More...
#include <RPC_Request_Callback.h>
|
| | RPC_Request_Callback ()=default |
| | Constructs empty callback, will result in never being called. Internals are simply default constructed as nullptr. More...
|
| |
| | RPC_Request_Callback (char const *method_name, function callback, JsonArray const *parameters=nullptr, uint64_t const &timeout_microseconds=0U, Callback_Watchdog::function timeout_callback=nullptr) |
| | Constructs callback, will be called upon RPC response arrival originating from the original client side RPC request with any optional additional parameters that should be passed to the method. More...
|
| |
| | ~RPC_Request_Callback () override=default |
| |
| size_t const & | Get_Request_ID () const |
| | Gets the unique request identifier that is connected to the original request. More...
|
| |
| void | Set_Request_ID (size_t const &request_id) |
| | Sets the unique request identifier that is connected to the original request. More...
|
| |
| char const * | Get_Name () const |
| | Gets the name of the client-side RPC method we want to call on the cloud so that this method callback will be executed. More...
|
| |
| void | Set_Name (char const *method_name) |
| | Sets the name of the client side RPC method we want to call on the cloud so that this method callback will be executed. More...
|
| |
| JsonArray const * | Get_Parameters () const |
| | Gets the paramaters we want to call the client-side RPC method on the cloud with. More...
|
| |
| void | Set_Parameters (JsonArray const *parameters) |
| | Sets the paramaters we want to call the client-side RPC method with on the cloud with. More...
|
| |
| Timeoutable_Request & | Get_Request_Timeout () |
| | Gets the request timeout callback. More...
|
| |
| | Callback ()=default |
| | Constructs empty callback, will result in never being called. Internals are simply default constructed as nullptr. More...
|
| |
| | Callback (function callback) |
| | Constructor. More...
|
| |
| virtual | ~Callback ()=default |
| | Virtual default destructor, created to ensure that if a pointer to this class is used and deleted, we will also call the derived base class destructor. More...
|
| |
| void | Call_Callback (argument_types const &... arguments) const |
| | Calls the callback that was subscribed, when this class instance was initally created. More...
|
| |
| void | Set_Callback (function callback) |
| | Sets the callback method that will be called upon data arrival with the given data that was received. If nullptr is passed the callback will never be called and instead return with a defaulted instance of the requested return variable. More...
|
| |
Client-side RPC callback wrapper, contains the needed configuration settings to create the request that should be sent to the server. Documentation about the specific use of client-side RPC in ThingsBoard can be found here https://thingsboard.io/docs/user-guide/rpc/#client-side-rpc.
◆ RPC_Request_Callback() [1/2]
| RPC_Request_Callback::RPC_Request_Callback |
( |
| ) |
|
|
default |
Constructs empty callback, will result in never being called. Internals are simply default constructed as nullptr.
◆ RPC_Request_Callback() [2/2]
| RPC_Request_Callback::RPC_Request_Callback |
( |
char const * |
method_name, |
|
|
function |
callback, |
|
|
JsonArray const * |
parameters = nullptr, |
|
|
uint64_t const & |
timeout_microseconds = 0U, |
|
|
Callback_Watchdog::function |
timeout_callback = nullptr |
|
) |
| |
Constructs callback, will be called upon RPC response arrival originating from the original client side RPC request with any optional additional parameters that should be passed to the method.
- Parameters
-
| method_name | Non owning pointer to the name of the client-side RPC method we want to call on the cloud so that this method callback will be executed. Additionally it has to be kept alive by the user until the RPC_Request method has been called with this instance as the argument, because that method copies the data into the outgoing MQTT buffer to create the client-side RPC request |
| callback | callback method that will be called upon data arrival with the given data that was received. If nullptr is passed the callback will never be called and instead return with a defaulted instance of the requested return variable |
| parameters | Optional Non-owning pointer to the paramaters we want to call the client-side RPC method with. Use nullptr if the client-side RPC method expects no arguments. Additionally it has to be kept alive by the user until the RPC_Request method has been called with this instance as the argument, because that method copies the data into the outgoing MQTT buffer to create the client-side RPC request, default = nullptr |
| timeout_microseconds | Optional amount of microseconds until a response should have been received from the server, counted from the moment the request is sent. If a response is not received in the timeout time, the timeout callback method will be called to inform the user that the request has failed. If the value is 0 the timer will not be started and therefore never call the timeout callback method, default = 0 |
| timeout_callback | Optional callback method that will be called upon request timeout (did not receive a response in the given timeout time). Can happen if the requested method does not exist on the cloud, or if the connection could not be established. A nullptr means even if a timeout occured the callback is simply ignored and the user not informed, default = nullptr |
◆ ~RPC_Request_Callback()
| RPC_Request_Callback::~RPC_Request_Callback |
( |
| ) |
|
|
overridedefault |
◆ Get_Name()
| char const * RPC_Request_Callback::Get_Name |
( |
| ) |
const |
Gets the name of the client-side RPC method we want to call on the cloud so that this method callback will be executed.
- Returns
- Non owning pointer to the name of the client-side RPC method. Owned by the user that passed it originally in the constructor or with the Set_Name method
◆ Get_Parameters()
| JsonArray const * RPC_Request_Callback::Get_Parameters |
( |
| ) |
const |
Gets the paramaters we want to call the client-side RPC method on the cloud with.
- Returns
- Non-owning pointer to the paramaters we want to call the client-side RPC method with. Owned by the user that passed it originally in the constructor or with the Set_Parameters method
◆ Get_Request_ID()
| size_t const & RPC_Request_Callback::Get_Request_ID |
( |
| ) |
const |
Gets the unique request identifier that is connected to the original request.
- Note
- Will be later used to verifiy which RPC_Request_Callback is connected to which received client-side RPC response
- Returns
- Unique identifier connected to the requested client-side or shared attribute response
◆ Get_Request_Timeout()
Gets the request timeout callback.
- Note
- Will be called when no response to the request was received in the expected amount of time, causing the internal watchdog to time out. To achieve this behaviour the internal timer can be started and stopped, and simply calls the subscribed callback if the timer is not stopped before it times out
- Returns
- Request timeout callback
◆ Set_Name()
| void RPC_Request_Callback::Set_Name |
( |
char const * |
method_name | ) |
|
Sets the name of the client side RPC method we want to call on the cloud so that this method callback will be executed.
- Parameters
-
| method_name | Non owning pointer to the name of the client-side RPC method. Additionally it has to be kept alive by the user until the RPC_Request method has been called with this instance as the argument, because that method copies the data into the outgoing MQTT buffer to create the client-side RPC request |
◆ Set_Parameters()
| void RPC_Request_Callback::Set_Parameters |
( |
JsonArray const * |
parameters | ) |
|
Sets the paramaters we want to call the client-side RPC method with on the cloud with.
- Note
- The value of nullptr, means the client-side RPC method is called with no parameters
- Parameters
-
| parameters | Non-owning pointer to the paramaters we want to call the client-side RPC method with Additionally it has to be kept alive by the user until the RPC_Request method has been called with this instance as the argument, because that method copies the data into the outgoing MQTT buffer to create the client-side RPC request |
◆ Set_Request_ID()
| void RPC_Request_Callback::Set_Request_ID |
( |
size_t const & |
request_id | ) |
|
Sets the unique request identifier that is connected to the original request.
- Note
- Will be later used to verifiy which RPC_Request_Callback is connected to which received client-side RPC response. Not meant for external use, because the value is overwritten by internal method calls anyway once the class instance has been passed as a parameter anyway. This is the case because only the internal methods knows the current request id that this callback will be attached too
- Parameters
-
| request_id | Unqiue identifier of the request for client-side RPC |
The documentation for this class was generated from the following files: