libknx
|
This class handles the ip connection(s) to the knx gateway. More...
#include <connection.hpp>
Public Member Functions | |
connection (const knx::config &config) | |
creates the connection with given config | |
~connection () | |
simple destructor | |
void | start () |
blocking start of the connection background thread More... | |
void | stop () |
non-blocking stop of the background thread More... | |
template<typename data_type > | |
void | set (knx::group group, typename data_type::major_type::set_type data) |
central function to set any knx group value on the bus More... | |
template<typename data_type > | |
bool | get (knx::group group, typename data_type::major_type::set_type &data) |
central function to get any knx group value from the bus More... | |
template<typename data_type > | |
bool | listen (knx::group group, std::function< void(typename data_type::major_type::set_type &) > callback) |
central function to continously get any knx group value from the bus More... | |
bool | set_heartbeat_callback (std::function< void()> callback) |
set a callback which is notified as soon as a heartbeat response is received. More... | |
bool | wait_until_connected () |
Waiting for connection to be established. More... | |
This class handles the ip connection(s) to the knx gateway.
bool knx::connection::get | ( | knx::group | group, |
typename data_type::major_type::set_type & | data | ||
) |
central function to get any knx group value from the bus
This function is used to get any value from the knx bus.
group | A valid group id as string (e.g. "1/2/3") |
bool knx::connection::listen | ( | knx::group | group, |
std::function< void(typename data_type::major_type::set_type &) > | callback | ||
) |
central function to continously get any knx group value from the bus
This function is used to listen for any value from the knx bus.
A minimal example would be:
group | A valid group id as string (e.g. "1/2/3") |
callback | A function to be called whenever data has been received |
void knx::connection::set | ( | knx::group | group, |
typename data_type::major_type::set_type | data | ||
) |
central function to set any knx group value on the bus
This function is used to set any value on the knx bus.
bool knx::connection::set_heartbeat_callback | ( | std::function< void()> | callback | ) |
set a callback which is notified as soon as a heartbeat response is received.
callback | A function without parameters to be called as soon as the heartbeat arrives |
void knx::connection::start | ( | ) |
blocking start of the connection background thread
This function is a blocking call to start the background thread. It is normally only called by the handler.
void knx::connection::stop | ( | ) |
non-blocking stop of the background thread
This function send the termination signals and waits for the thread to stop.
bool knx::connection::wait_until_connected | ( | ) |
Waiting for connection to be established.
This function waits until at least one connection reponse has been received. Be aware that this is NOT an guarantee that the connection is still alive when you submit the first message. This function is useful to prevent sending a message before the connection is at least once established.