Index: trunk/Arduino/projects/OT_slave/OT_slave.ino
===================================================================
--- trunk/Arduino/projects/OT_slave/OT_slave.ino	(revision 3)
+++ trunk/Arduino/projects/OT_slave/OT_slave.ino	(revision 4)
@@ -4,19 +4,37 @@
 #define THERMOSTAT_OUT 4
 
-OpenthermData message;
+class OT_V2R2_Slave {
 
-void setup() {
+protected:
+  static OpenthermData message;
+  
+
+public:
+  OT_V2R2_Slave ();
+
+  virtual void  Setup ();
+  virtual void  Loop ();
+
+private:
+  static void ListenAfterResponse ();
+
+};
+
+static OpenthermData  OT_V2R2_Slave::message;
+
+OT_V2R2_Slave::OT_V2R2_Slave ()
+{
+}
+
+void  OT_V2R2_Slave::Setup ()
+{
   pinMode(THERMOSTAT_IN, INPUT);
   digitalWrite(THERMOSTAT_OUT, HIGH);
   pinMode(THERMOSTAT_OUT, OUTPUT); // low output = high current, high output = low current
-
-  Serial.begin(19200);
+  
 }
 
-/**
- * Loop will act as boiler (slave) connected to Opentherm thermostat.
- * It will wait for requests from thermostat and response with unknown data id as a fake response.
- */
-void loop() {
+void  OT_V2R2_Slave::Loop ()
+{
   if (OPENTHERM::getMessage(message)) {
     Serial.print("-> ");
@@ -27,5 +45,5 @@
     message.valueHB = 0;
     message.valueLB = 0;
-    OPENTHERM::send(THERMOSTAT_OUT, message, listenAfterResponse); // send some response and wait for antoher request from thermostat set by callback
+    OPENTHERM::send(THERMOSTAT_OUT, message, OT_V2R2_Slave::ListenAfterResponse); // send some response and wait for antoher request from thermostat set by callback
   }
   else if (OPENTHERM::isSent() || OPENTHERM::isIdle() || OPENTHERM::isError()) { // wait for request from thermostat
@@ -34,5 +52,6 @@
 }
 
-void listenAfterResponse() {
+void  OT_V2R2_Slave::ListenAfterResponse() 
+{
   Serial.print("<- ");
   OPENTHERM::printToSerial(message);
@@ -41,2 +60,19 @@
   OPENTHERM::listen(THERMOSTAT_IN, -1);
 }
+
+OT_V2R2_Slave boiler;
+
+void setup() 
+{
+  boiler.Setup();
+  Serial.begin(19200);
+}
+
+/**
+ * Loop will act as boiler (slave) connected to Opentherm thermostat.
+ * It will wait for requests from thermostat and response with unknown data id as a fake response.
+ */
+void loop() 
+{
+  boiler.Loop();
+}
