BAOS SDK v2
1.0.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
|
A specialization for connection to the BAOS device via a TCP connection. More...
#include <baos/ip/BaosTcpConnection.h>
Public Types | |
using | UPtr = std::unique_ptr< BaosTcpConnection > |
Alias for a std::unique_ptr to this class. | |
using | TcpTransportFrame = Buffer |
Alias on how a TcpTransportFrame is represented. | |
![]() | |
using | Clock = std::chrono::system_clock |
An alias for the clock internaly used. | |
using | BaosFrame = Buffer |
An alias for the container type to store frame/packets/telegrams in. | |
using | BaosFrame_UPtr = std::unique_ptr< BaosFrame > |
An alias for a std::unique_ptr holding a BaosFrame. | |
using | UPtr = std::unique_ptr< BaosConnection > |
An alias for an unqiue pointer to this class. | |
using | ServerItemIndicationCb = std::function< void(const protocol::ServerItems &)> |
Function signature for serveritem indication callbacks. | |
using | DatapointValueCb = std::function< void(const protocol::DatapointValueStates &)> |
Function signature for datapoint value indication callbacks. | |
Public Member Functions | |
void | open (const std::string &ip4Address, std::uint16_t port=12004) |
Open a connection to physical BAOS device. More... | |
void | reopen () override |
Reopens the underlying connection, has to be implemented by derived classes. | |
![]() | |
BaosConnection () | |
Default constructor. | |
virtual | ~BaosConnection () |
Default destructor. | |
void | start () |
Start the client side of the connection. | |
void | stop () |
Stop the client side of the connection. | |
void | close () |
Close the connection to the BAOS device. | |
bool | isOpen () |
Returns the open state of the connection. More... | |
void | setServerItemsIndCallback (ServerItemIndicationCb callback) |
void | setDatapointValueIndCallback (DatapointValueCb callback) |
std::optional< protocol::ServerItem > | getServerItem (protocol::ServerItemId id) |
Get a single the ServerItem. More... | |
protocol::ServerItems | getServerItems (std::uint16_t startItem, std::uint16_t numberOfItems) |
Get a list of serveritems from the device. More... | |
void | setServerItem (const protocol::ServerItem &serverItem) |
void | setServerItem (protocol::ServerItem &&serverItem) |
void | setServerItems (protocol::ServerItems &&serverItems) |
std::optional< protocol::DatapointDescription > | getDpDescription (std::uint16_t dpId) |
Get the datapoint description for one datapoint. More... | |
protocol::DatapointDescriptions | getDpDescriptions (std::uint16_t startDpId, std::uint16_t numberOfItems) |
Get a list of DatapointDescriptions. More... | |
std::optional< protocol::DatapointDescriptionString > | getDpDescriptionString (std::uint16_t dpId) |
Get the datapoint description string for one datapoint. More... | |
protocol::DatapointDescriptionStrings | getDpDescriptionStrings (std::uint16_t startDpId, std::uint16_t numberOfStrings) |
Get a list of DatapointDescriptionsStrings. More... | |
std::optional< std::uint8_t > | getParameterByte (std::uint16_t byteIndex) |
Get a single parameter byte. | |
protocol::ParameterBytes | getParameterBytes (std::uint16_t byteIndex, std::uint16_t numberOfBytes) |
Get a list of parameter bytes. More... | |
std::optional< protocol::DatapointValueState > | getDpValue (std::uint16_t dpId) |
Get a single datapoint value with its associated state. | |
protocol::DatapointValueStates | getDpValues (std::uint16_t startDpId, std::uint16_t numberOfValues, protocol::DatapointValueFilter filter=protocol::DatapointValueFilter::ALL) |
Get a map with the datapoint id as key and the DatapointValueState as value. More... | |
void | setDpValue (std::uint16_t dpId, protocol::DatapointChangeValue &&dpValue) |
Send a SetDatapointValue request to the BAOS device for one datapoint. More... | |
void | setDpValues (std::map< std::uint16_t, protocol::DatapointChangeValue > &&dpValues) |
Send a SetDatapointValue request to the BAOS device with given datapoint values. More... | |
protocol::ResponseFuture | getServerItemAsync (protocol::ServerItemId id) |
protocol::ResponseFuture | getServerItemsAsync (std::uint16_t startItem, std::uint16_t numberOfItems) |
Get a list of serveritems from the device. More... | |
protocol::ResponseFuture | setServerItemAsync (protocol::ServerItem &&serverItem) |
protocol::ResponseFuture | setServerItemsAsync (protocol::ServerItems &&serverItems) |
protocol::ResponseFuture | getDpDescriptionAsync (std::uint16_t dpId) |
Get the datapoint description for one datapoint. More... | |
protocol::ResponseFuture | getDpDescriptionsAsync (std::uint16_t startDpId, std::uint16_t numberOfItems) |
Get a list of DatapointDescriptions. More... | |
protocol::ResponseFuture | getDpDescriptionStringAsync (std::uint16_t dpId) |
Get the datapoint description string for one datapoint. More... | |
protocol::ResponseFuture | getDpDescriptionStringsAsync (std::uint16_t startDpId, std::uint16_t numberOfStrings) |
Get a list of DatapointDescriptionsStrings. More... | |
protocol::ResponseFuture | getParameterByteAsync (std::uint16_t byteIndex) |
Get a single parameter byte. | |
protocol::ResponseFuture | getParameterBytesAsync (std::uint16_t byteIndex, std::uint16_t numberOfBytes) |
Get a list of parameter bytes. More... | |
protocol::ResponseFuture | getDpValueAsync (std::uint16_t dpId) |
Get a single datapoint value with its associated state. | |
protocol::ResponseFuture | getDpValuesAsync (std::uint16_t startDpId, std::uint16_t numberOfValues, protocol::DatapointValueFilter filter=protocol::DatapointValueFilter::ALL) |
Get a map with the datapoint id as key and the DatapointValueState as value. More... | |
protocol::ResponseFuture | setDpValueAsync (std::uint16_t dpId, protocol::DatapointChangeValue &&dpValue) |
Send a SetDatapointValue request to the BAOS device for one datapoint. More... | |
protocol::ResponseFuture | setDpValuesAsync (std::map< std::uint16_t, protocol::DatapointChangeValue > &&dpValues) |
Send a SetDatapointValue request to the BAOS device with given datapoint values. More... | |
protocol::ResponseFuture | closeAsync () |
Close the connection. More... | |
Protected Member Functions | |
bool | isOpenImpl () override |
The implementation function for getting the opened state of the connection. More... | |
TcpTransportFrame | wrapKNXnetIp (BaosFrame &&frame) |
Wrap a baos frame into a KnxNet/Ip frame. More... | |
protocol::ResponseFuture | closeImplAsync () override |
The implementation function for closing a connection. | |
void | startImpl () override |
The implementation function for starting the connection class. | |
void | eventHandler () |
Handles the incoming IOEvents. | |
void | handleRxTcp (IOEvent &&event) |
Called for every Rx IOEvent (incoming, received) More... | |
void | handleTxTcp (IOEvent &&event) |
Called for every Tx IOEvent (outgoing, send, transmit) More... | |
protocol::ResponseFuture | sendImpl (BaosFrame &&frame) override |
The implementation function for sending bytes to the connected device. | |
void | onStateChange (State oldState, State newState) override |
Invoked if the internal connection state should be changed. | |
![]() | |
protocol::ResponseFuture | send (BaosFrame &&frame) |
Sends a generic frame( a byte list) to the BAOS device. More... | |
BaosParseStatus | handleBaosFrame (BaosFrame_UPtr &&frame) |
For every received BAOS frame this handler is internally called. More... | |
BaosParseStatus | handleBaosIndication (BaosFrame_UPtr &&frame) |
For every received BAOS indication this handler is internally called. More... | |
protocol::BaosResponseCode | handleBaosResponse (BaosFrame_UPtr &&frame) |
For every received BAOS response this handler is internally called. More... | |
State | setState (State newState) |
Set the internal state of this connections state machine. More... | |
State | getState () const |
Get the current internal state of this connections state machine. More... | |
protocol::BaosBaseResponse::SPtr | decodeResponse (BaosFrame_UPtr &&frame) |
Decodes the baos response. More... | |
virtual void | stopImpl () |
The implementation function for stopping the connection class. | |
virtual void | onTimerExpired (std::vector< std::uint64_t > ids) |
Invoked if on of the timers has expired. | |
Additional Inherited Members | |
![]() | |
enum class | State { RUNNING , STOPPING , STOPPED , SENDING , SENDCOMPLETE , WAITRESPONSE , IDLE , CONERROR , CONCLOSED } |
Represents the internal state of this connection. More... | |
enum class | PromiseState { UNUSED , SET , RESOLVED } |
The asynchronous functions return a promise to keep internal track of their state this enum is used. | |
![]() | |
static std::string | stateToString (State state) |
Get human readable string from internal state. | |
![]() | |
std::atomic< bool > | shouldStop_ {false} |
Flag to indicate that the connection should stop at the next opportunity. | |
std::atomic< bool > | isRunning_ {false} |
Keep track if the connection is in running state or stopping / stopped. More... | |
wzcpp::ThreadPoolExecutor | executor_ {4} |
wzcpp::TimerManager< Clock > | timerManager_ |
Manages the timers for this connection. | |
wzcpp::Timer< Clock > | respTimeoutTimer_ |
The actual timer objects for respone timeouts. | |
wzcpp::Timer< Clock > | heartBeatTimer_ |
The actual timer objects for heartbeats. | |
Buffer | waitResponse_ |
While waiting for a response this holds the pattern of the response we expect. | |
protocol::ResponsePromise | responsePromise_ |
If a packet is send out via handleTxTcp the corresponding promise is stored here. | |
PromiseState | responsePromiseState_ {PromiseState::UNUSED} |
The state of the responsePromise_. | |
std::uint64_t | currentMessageId_ {0} |
For internal use a unique message id. | |
std::queue< IOEvent > | txQueue_ |
Holds the packets to send waiting to be processed. | |
BaosMsgQueue | bMsgQ_ |
Hold the event for the main connection loop. | |
protocol::BaosIndQueue | bIndQ_ |
Holds the indication to be send out to clients. | |
BaosIndicationSender | indSender_ |
Responsible for sending out the indications. | |
A specialization for connection to the BAOS device via a TCP connection.
void open | ( | const std::string & | ip4Address, |
std::uint16_t | port = 12004 |
||
) |
Open a connection to physical BAOS device.
ip4Address | The IPv4 Address as string in the form "xxx.xxx.xxx.xxx" |
port | The tcp port of the remote device |
|
inlineoverrideprotectedvirtual |
The implementation function for getting the opened state of the connection.
Reimplemented from BaosConnection.
|
protected |
Wrap a baos frame into a KnxNet/Ip frame.
frame | The BaosFrame to wrap |
|
protected |
|
protected |