AWS IoT C++ SDK
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
awsiotsdk::discovery::DiscoverAction Class Reference

Define a class for DiscoverAction. More...

#include <Discovery.hpp>

Inheritance diagram for awsiotsdk::discovery::DiscoverAction:
awsiotsdk::Action

Public Member Functions

 DiscoverAction (const DiscoverAction &)=delete
 
 DiscoverAction (DiscoverAction &&)=delete
 
DiscoverActionoperator= (const DiscoverAction &) &=delete
 
DiscoverActionoperator= (DiscoverAction &&) &=delete
 
 DiscoverAction (std::shared_ptr< mqtt::ClientState > p_client_state)
 Constructor. More...
 
ResponseCode PerformAction (std::shared_ptr< NetworkConnection > p_network_connection, std::shared_ptr< ActionData > p_action_data)
 Performs the Discovery Action. More...
 
- Public Member Functions inherited from awsiotsdk::Action
ActionType GetActionType ()
 Get Type of this Action. More...
 
util::String GetActionInfo ()
 Get information/description about the current action. More...
 
void SetParentThreadSync (std::shared_ptr< std::atomic_bool > p_thread_continue)
 Sets the parent thread sync variable. More...
 
virtual ResponseCode PerformAction (std::shared_ptr< NetworkConnection > p_network_connection, std::shared_ptr< ActionData > p_action_data)=0
 Virtual base function for Performing Action. More...
 
 Action (const Action &)=delete
 
 Action (Action &&)=delete
 
Actionoperator= (const Action &) &=delete
 
Actionoperator= (Action &&) &=delete
 
 Action (ActionType action_type, util::String action_info_string)
 Action Constructor. More...
 

Static Public Member Functions

static std::unique_ptr< ActionCreate (std::shared_ptr< ActionState > p_action_state)
 Factory Create method. More...
 

Protected Member Functions

ResponseCode ReadResponseFromNetwork (std::shared_ptr< NetworkConnection > p_network_connection, util::String &sent_packet, util::String &read_payload, std::chrono::milliseconds max_response_wait_time)
 Parses the discovery response to get the header and response data. More...
 
ResponseCode MakeDiscoveryRequest (std::shared_ptr< NetworkConnection > p_network_connection, const util::String packet_data)
 Make the discovery request. More...
 
ResponseCode InitializeDiscoveryResponseJson (const util::String received_response, std::shared_ptr< DiscoverRequestData > discover_packet)
 Initialize the discovery response json. More...
 
- Protected Member Functions inherited from awsiotsdk::Action
ResponseCode ReadFromNetworkBuffer (std::shared_ptr< NetworkConnection > p_network_connection, util::Vector< unsigned char > &read_buf, size_t bytes_to_read)
 Generic Network Read function for all actions. More...
 
ResponseCode WriteToNetworkBuffer (std::shared_ptr< NetworkConnection > p_network_connection, const util::String &write_buf)
 Generic Network Write function for all actions. More...
 

Protected Attributes

std::shared_ptr< mqtt::ClientStatep_client_state_
 Shared Client State instance.
 
- Protected Attributes inherited from awsiotsdk::Action
ActionType action_type_
 Type of the action.
 
util::String action_info_string_
 Info string.
 
std::shared_ptr< std::atomic_bool > p_thread_continue_
 Shared atomic variable used for sync when action is run in separate thread.
 

Additional Inherited Members

- Public Types inherited from awsiotsdk::Action
typedef std::function< std::unique_ptr< Action >(std::shared_ptr< ActionState > p_action_state)> CreateHandlerPtr
 

Detailed Description

This class defines a Synchronous action for performing an AWS Greengrass Discovery operation

Constructor & Destructor Documentation

◆ DiscoverAction()

awsiotsdk::discovery::DiscoverAction::DiscoverAction ( std::shared_ptr< mqtt::ClientState p_client_state)
Warning
This constructor can throw exceptions, it is recommended to use Factory create method Constructor is kept public to not restrict usage possibilities (eg. make_shared)
Parameters
p_client_state- Shared Client State instance

Member Function Documentation

◆ Create()

std::unique_ptr< Action > awsiotsdk::discovery::DiscoverAction::Create ( std::shared_ptr< ActionState p_action_state)
static
Parameters
p_client_state- Shared Client State instance
Returns
nullptr on error, unique_ptr pointing to a created DiscoverAction instance if successful

◆ InitializeDiscoveryResponseJson()

ResponseCode awsiotsdk::discovery::DiscoverAction::InitializeDiscoveryResponseJson ( const util::String  received_response,
std::shared_ptr< DiscoverRequestData discover_packet 
)
protected

Convert the received discovery response and insert it into the discover packet. Returns a SUCCESS if it able to covert it into a Json successfully. Returns error code otherwise.

Parameters
received_response
discover_packet
Returns
ResponseCode

◆ MakeDiscoveryRequest()

ResponseCode awsiotsdk::discovery::DiscoverAction::MakeDiscoveryRequest ( std::shared_ptr< NetworkConnection p_network_connection,
const util::String  packet_data 
)
protected

Writes the discovery request to the network. Returns a SUCCESS when it is able to write to the network correctly. Returns error code otherwise.

Parameters
p_network_connection
p_discover_packet
Returns
ResponseCode

◆ PerformAction()

ResponseCode awsiotsdk::discovery::DiscoverAction::PerformAction ( std::shared_ptr< NetworkConnection p_network_connection,
std::shared_ptr< ActionData p_action_data 
)
virtual

Performs the Discovery operation to get the connectivity information of GGCs in the group that this device belongs to by making an HTTP GET request to the endpoint. Returns a DISCOVER_ACTION_SUCCESS response when connectivity information is found. Otherwise returns error codes based on whether it's an HTTP error or if connectivity information is not present.

Parameters
p_network_connection
p_action_data
Returns
ResponseCode

Implements awsiotsdk::Action.

◆ ReadResponseFromNetwork()

ResponseCode awsiotsdk::discovery::DiscoverAction::ReadResponseFromNetwork ( std::shared_ptr< NetworkConnection p_network_connection,
util::String &  sent_packet,
util::String &  read_payload,
std::chrono::milliseconds  max_response_wait_time 
)
protected

Parses the discovery response to obtain the header and response payload. Returns a SUCCESS when it is able to parse it correctly. Otherwise returns error codes if the discovery request fails.

Parameters
sent_packet
read_payload
max_response_wait_time
Returns
ResponseCode