libknx
connection.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "debug.hpp"
4 
5 #include <functional>
6 
7 #include "config.hpp"
8 #include "dpt.hpp"
9 #include "group.hpp"
10 
15 namespace knx
16 {
17 
18 class connection_private;
19 
23 class KNX_IMPORT_EXPORT connection
24 {
25 public:
30 
33 
42  void start();
43 
49  void stop();
50 
56  template<typename data_type>
57  void set ( knx::group group, typename data_type::major_type::set_type data );
58 
67  template<typename data_type>
68  bool get ( knx::group group, typename data_type::major_type::set_type & data );
69 
100  template<typename data_type>
101  bool listen ( knx::group group, std::function<void ( typename data_type::major_type::set_type & ) > callback );
102 
127  bool set_heartbeat_callback(std::function<void ()> callback);
128 
129 private:
131  connection_private * connection_private_pointer;
133  connection ( connection & rhs );
135  connection & operator= ( connection & rhs );
136 };
137 
138 }
139 
This class represents the configuration of the knx connection.
Definition: config.hpp:19
This class handles the ip connection(s) to the knx gateway.
Definition: connection.hpp:24
bool get(knx::group group, typename data_type::major_type::set_type &data)
central function to get any knx group value from the bus
void set(knx::group group, typename data_type::major_type::set_type data)
central function to set any knx group value on the bus
~connection()
simple destructor
connection(const knx::config &config)
creates the connection with given config
void stop()
non-blocking stop of the background thread
void start()
blocking start of the connection background thread
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
bool set_heartbeat_callback(std::function< void()> callback)
set a callback which is notified as soon as a heartbeat response is received.
This class represents a KNX group address which might be either 3 compnent "a/b/c" or 2 component "a/...
Definition: group.hpp:17
separated namespace to embed all libknx related classes
Definition: config.hpp:13