ThingsBoard Client SDK 0.16.0
Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Timeoutable_Request Class Reference

General purpose request callback that can timeout if the response to the request is not received in the expected amount of time and the internal watchdog times out. More...

#include <Timeoutable_Request.h>

Public Member Functions

 Timeoutable_Request (uint64_t const &timeout_microseconds=0U, Callback_Watchdog::function timeout_callback=nullptr)
 Constructs request timeout callback. More...
 
uint64_t const & Get_Timeout () const
 Gets the amount of microseconds until we expect to have received a response. More...
 
void Set_Timeout (uint64_t const &timeout_microseconds)
 Sets the amount of microseconds until we expect to have received a response. More...
 
void Update_Timeout_Timer ()
 Updates the internal timeout timer. More...
 
void Start_Timeout_Timer ()
 Starts the internal timeout timer if we actually received a configured valid timeout time and a valid callback. More...
 
void Stop_Timeout_Timer ()
 Stops the internal timeout timer, is called as soon as an answer is received from the cloud. If this method is not called in time the initally subscribed callback will be used to inform the user of the timeout instead. More...
 
void Set_Timeout_Callback (Callback_Watchdog::function timeout_callback)
 Sets the callback method that will be called upon request timeout (did not receive a response from the cloud in the given timeout time) More...
 

Detailed Description

General purpose request callback that can timeout if the response to the request is not received in the expected amount of time and the internal watchdog times out.

Constructor & Destructor Documentation

◆ Timeoutable_Request()

Timeoutable_Request::Timeoutable_Request ( uint64_t const &  timeout_microseconds = 0U,
Callback_Watchdog::function  timeout_callback = nullptr 
)

Constructs 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
Parameters
timeout_microsecondsAmount 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_callbackCallback 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

Member Function Documentation

◆ Get_Timeout()

uint64_t const & Timeoutable_Request::Get_Timeout ( ) const

Gets the amount of microseconds until we expect to have received a response.

Returns
Timeout time until timeout callback is called

◆ Set_Timeout()

void Timeoutable_Request::Set_Timeout ( uint64_t const &  timeout_microseconds)

Sets the amount of microseconds until we expect to have received a response.

Note
The value of 0, means the timeout timer is never started and therefore the timeout callback never called
Parameters
timeout_microsecondsTimeout time until timeout callback is called

◆ Set_Timeout_Callback()

void Timeoutable_Request::Set_Timeout_Callback ( Callback_Watchdog::function  timeout_callback)

Sets the callback method that will be called upon request timeout (did not receive a response from the cloud in the given timeout time)

Parameters
timeout_callbackCallback function that will be called

◆ Start_Timeout_Timer()

void Timeoutable_Request::Start_Timeout_Timer ( )

Starts the internal timeout timer if we actually received a configured valid timeout time and a valid callback.

Note
The timeout time is valid if it is not 0 and the callback is valid if it is not a nullptr. Is not mean to be called explicitly by the user, because it is instead called when necessary by internal methods that handle the class instance

◆ Stop_Timeout_Timer()

void Timeoutable_Request::Stop_Timeout_Timer ( )

Stops the internal timeout timer, is called as soon as an answer is received from the cloud. If this method is not called in time the initally subscribed callback will be used to inform the user of the timeout instead.

Note
Is not mean to be called explicitly by the user, because it is instead called when necessary by internal methods that handle the class instance

◆ Update_Timeout_Timer()

void Timeoutable_Request::Update_Timeout_Timer ( )

Updates the internal timeout timer.


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