SensESP 3.4.1-alpha
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::AsyncResponseHandler Class Reference

Handle async command responses from remote systems. More...

#include <sensesp/system/async_response_handler.h>

Inheritance diagram for sensesp::AsyncResponseHandler:
[legend]

Public Member Functions

 AsyncResponseHandler ()
 
 AsyncResponseHandler (int timeout)
 
void activate ()
 Activate must be called when a command is sent to the remote system.
 
void set (const bool &success) override
 
const AsyncResponseStatus get_status () const
 
- Public Member Functions inherited from sensesp::ValueConsumer< bool >
virtual void set_input (const bool &new_value)
 
void connect_from (ValueProducer< bool > *producer)
 
- Public Member Functions inherited from sensesp::ValueProducer< AsyncResponseStatus >
 ValueProducer ()
 
 ValueProducer (const AsyncResponseStatus &initial_value)
 
virtual const AsyncResponseStatusget () const
 
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< AsyncResponseStatus, typenameVConsumer::input_type >::value, std::shared_ptr< VConsumer > >::type connect_to (std::shared_ptr< VConsumer > consumer)
 Connect a producer to a transform with a different input type.
 
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< AsyncResponseStatus, typenameVConsumer::input_type >::value, VConsumer * >::type connect_to (VConsumer *consumer)
 
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< AsyncResponseStatus, typenameVConsumer::input_type >::value, VConsumer * >::type connect_to (VConsumer &consumer)
 
void emit (const AsyncResponseStatus &new_value)
 
- Public Member Functions inherited from sensesp::Observable
 Observable ()
 
 Observable (Observable &&other)
 Move constructor.
 
void notify ()
 
int attach (std::function< void()> observer)
 Attach an observer callback.
 
void detach (int id)
 Remove a previously attached observer by its ID.
 

Protected Attributes

reactesp::DelayEvent * timeout_event_ = nullptr
 
AsyncResponseStatus status_ = AsyncResponseStatus::kReady
 
int timeout_ = 3000
 
- Protected Attributes inherited from sensesp::ValueProducer< AsyncResponseStatus >
AsyncResponseStatus output_
 

Additional Inherited Members

- Public Types inherited from sensesp::ValueConsumer< bool >
using input_type = bool
 

Detailed Description

Handle async command responses from remote systems.

This class is used to report responses to commands sent to a remote system. The class should consume a boolean value when a response is received. The boolean value indicates whether the command was successful or not. The response handler also emits the response status to its subscribers.

Definition at line 30 of file async_response_handler.h.

Constructor & Destructor Documentation

◆ AsyncResponseHandler() [1/2]

sensesp::AsyncResponseHandler::AsyncResponseHandler ( )
inline

Definition at line 33 of file async_response_handler.h.

◆ AsyncResponseHandler() [2/2]

sensesp::AsyncResponseHandler::AsyncResponseHandler ( int  timeout)
inline

Definition at line 35 of file async_response_handler.h.

Member Function Documentation

◆ activate()

void sensesp::AsyncResponseHandler::activate ( )
inline

Activate must be called when a command is sent to the remote system.

Parameters
value

Definition at line 45 of file async_response_handler.h.

Here is the call graph for this function:

◆ get_status()

const AsyncResponseStatus sensesp::AsyncResponseHandler::get_status ( ) const
inline

Definition at line 89 of file async_response_handler.h.

◆ set()

void sensesp::AsyncResponseHandler::set ( const bool &  new_value)
inlineoverridevirtual

Used to set an input of this consumer. It is called automatically by a ValueProducer but can also be called manually.

Parameters
new_valuethe value of the input

Reimplemented from sensesp::ValueConsumer< bool >.

Definition at line 65 of file async_response_handler.h.

Here is the call graph for this function:

Member Data Documentation

◆ status_

AsyncResponseStatus sensesp::AsyncResponseHandler::status_ = AsyncResponseStatus::kReady
protected

Definition at line 93 of file async_response_handler.h.

◆ timeout_

int sensesp::AsyncResponseHandler::timeout_ = 3000
protected

Definition at line 94 of file async_response_handler.h.

◆ timeout_event_

reactesp::DelayEvent* sensesp::AsyncResponseHandler::timeout_event_ = nullptr
protected

Definition at line 92 of file async_response_handler.h.


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