HDLC-Daemon
HdlcdClient Class Reference

Class HdlcdClient. More...

#include <HdlcdClient.h>

Public Member Functions

 HdlcdClient (boost::asio::io_service &a_IOService, const std::string &a_SerialPortName, HdlcdSessionDescriptor a_HdlcdSessionDescriptor)
 The constructor of HdlcdClient objects. More...
 
void AsyncConnect (boost::asio::ip::tcp::resolver::iterator a_EndpointIterator, std::function< void(bool a_bSuccess)> a_OnConnectedCallback)
 Perform an asynchronous connect procedure regarding both TCP sockets. More...
 
 ~HdlcdClient ()
 The destructor of HdlcdClient objects. More...
 
void Shutdown ()
 Shuts all TCP connections down. More...
 
void Close ()
 Close the client entity. More...
 
void SetOnDataCallback (std::function< void(const HdlcdPacketData &a_PacketData)> a_OnDataCallback)
 Provide a callback method to be called for received data packets. More...
 
void SetOnCtrlCallback (std::function< void(const HdlcdPacketCtrl &a_PacketCtrl)> a_OnCtrlCallback)
 Provide a callback method to be called for received control packets. More...
 
void SetOnClosedCallback (std::function< void()> a_OnClosedCallback)
 Provide a callback method to be called if this client entity is closing. More...
 
bool Send (const HdlcdPacketData &a_PacketData, std::function< void()> a_OnSendDoneCallback=nullptr)
 Send a single data packet to the peer entity. More...
 
bool Send (const HdlcdPacketCtrl &a_PacketCtrl, std::function< void()> a_OnSendDoneCallback=nullptr)
 Send a single control packet to the peer entity. More...
 

Detailed Description

Class HdlcdClient.

The main helper class to easily implement clients of the HDLCd access protocol. It implements the HDLCd access protocol and makes use of two TCP sockets: one TCP socket is dedicated to the exchange of user data, the second solely to the exchange of control packets. However, all the socket handling is performed internally and is not visible to the user of this class.

This class provides an asynchronous interface, but it can also be used in a quasi-synchronous way.

Definition at line 60 of file HdlcdClient.h.

Constructor & Destructor Documentation

HdlcdClient::HdlcdClient ( boost::asio::io_service &  a_IOService,
const std::string &  a_SerialPortName,
HdlcdSessionDescriptor  a_HdlcdSessionDescriptor 
)
inline

The constructor of HdlcdClient objects.

Parameters
a_IOServicethe boost IOService object
a_SerialPortNamethe name of the serial port device
a_HdlcdSessionDescriptorthe indentifier of the session, see "service access point"

Definition at line 68 of file HdlcdClient.h.

HdlcdClient::~HdlcdClient ( )
inline

The destructor of HdlcdClient objects.

All open connections will automatically be closed by the destructor

Definition at line 118 of file HdlcdClient.h.

Here is the call graph for this function:

Member Function Documentation

void HdlcdClient::AsyncConnect ( boost::asio::ip::tcp::resolver::iterator  a_EndpointIterator,
std::function< void(bool a_bSuccess)>  a_OnConnectedCallback 
)
inline

Perform an asynchronous connect procedure regarding both TCP sockets.

Parameters
a_EndpointIteratorthe boost endpoint iteratior referring to the destination
a_OnConnectedCallbackthe callback to be called if a result is available.

Definition at line 84 of file HdlcdClient.h.

void HdlcdClient::Close ( )
inline

Close the client entity.

Close the client entity and all its TCP connections

Definition at line 143 of file HdlcdClient.h.

Here is the caller graph for this function:

bool HdlcdClient::Send ( const HdlcdPacketData a_PacketData,
std::function< void()>  a_OnSendDoneCallback = nullptr 
)
inline

Send a single data packet to the peer entity.

Send a single data packet to the peer entity. Due to the asynchronous mode the data packet is enqueued for later transmission.

Parameters
a_PacketDatathe data packet to be transmitted
a_OnSendDoneCallbackthe callback handler to be called if the provided data packet was sent (optional)
Return values
truethe data packet was enqueued for transmission
falsethe data packet was not enqueued, e.g., the send queue was full or a problem with one of the sockets occured
Returns
Indicates whether the provided data packet was successfully enqueued for transmitted

Definition at line 209 of file HdlcdClient.h.

bool HdlcdClient::Send ( const HdlcdPacketCtrl a_PacketCtrl,
std::function< void()>  a_OnSendDoneCallback = nullptr 
)
inline

Send a single control packet to the peer entity.

Send a single control packet to the peer entity. Due to the asynchronous mode the control packet is enqueued for later transmission.

Parameters
a_PacketCtrlthe control packet to be transmitted
a_OnSendDoneCallbackthe callback handler to be called if the provided control packet was sent (optional)
Return values
truethe control packet was enqueued for transmission
falsethe control packet was not enqueued, e.g., the send queue was full or a problem with one of the sockets occured
Returns
Indicates whether the provided control packet was successfully enqueued for transmitted

Definition at line 233 of file HdlcdClient.h.

Here is the call graph for this function:

void HdlcdClient::SetOnClosedCallback ( std::function< void()>  a_OnClosedCallback)
inline

Provide a callback method to be called if this client entity is closing.

This method can be used to provide a function pointer callback to be called if this entoty is closing, e.g., the peer closed its endpoint

Parameters
a_OnClosedCallbackthe funtion pointer to the callback method, may be an empty function pointer to remove the callback

Definition at line 194 of file HdlcdClient.h.

void HdlcdClient::SetOnCtrlCallback ( std::function< void(const HdlcdPacketCtrl &a_PacketCtrl)>  a_OnCtrlCallback)
inline

Provide a callback method to be called for received control packets.

Control packets are received in an asynchronous way. Use this method to specify a callback method to be called on reception of single control packets

Parameters
a_OnCtrlCallbackthe funtion pointer to the callback method, may be an empty function pointer to remove the callback

Definition at line 184 of file HdlcdClient.h.

void HdlcdClient::SetOnDataCallback ( std::function< void(const HdlcdPacketData &a_PacketData)>  a_OnDataCallback)
inline

Provide a callback method to be called for received data packets.

Data packets are received in an asynchronous way. Use this method to specify a callback method to be called on reception of single data packets

Parameters
a_OnDataCallbackthe funtion pointer to the callback method, may be an empty function pointer to remove the callback

Definition at line 174 of file HdlcdClient.h.

void HdlcdClient::Shutdown ( )
inline

Shuts all TCP connections down.

Initiates a shutdown procedure for correct teardown of all TCP connections

Definition at line 129 of file HdlcdClient.h.


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