Index: trunk/Arduino/projects/OT_boiler/OT_boiler.ino
===================================================================
--- trunk/Arduino/projects/OT_boiler/OT_boiler.ino	(revision 3)
+++ trunk/Arduino/projects/OT_boiler/OT_boiler.ino	(revision 7)
@@ -1,8 +1,5 @@
 #include <SPI.h>
 #include <Ethernet.h>
-#include <opentherm.h>
-
-#define THERMOSTAT_IN 2
-#define THERMOSTAT_OUT  4
+#include <ot_slave_2.h>
 
 byte  mac[] = { 0x02, 0xDE, 0xAD, 0xDE, 0xAD, 0x01 };
@@ -12,5 +9,5 @@
 volatile bool  _connected = false;
 
-OpenthermData message;
+OT_V2R2_Slave boiler;
 
 EthernetClient client;
@@ -18,7 +15,5 @@
 void setup() 
 {
-  pinMode(THERMOSTAT_IN, INPUT);
-  digitalWrite(THERMOSTAT_OUT, HIGH);
-  pinMode(THERMOSTAT_OUT, OUTPUT); // low output = high current, high output = low current
+  boiler.Setup();
 
   // Console
@@ -51,4 +46,5 @@
 void loop() 
 {
+/*
   Serial.print("[");
   Serial.print(++loops);
@@ -56,28 +52,10 @@
   Serial.print(state,HEX);
   Serial.println("]");
+*/
   maintainEthernet();
-  if (OPENTHERM::getMessage(message)) {
-    Serial.print("-> ");
-    OPENTHERM::printToSerial(message);
-    Serial.println();
-    Sent_OT_Data(message);
-
-    delay(100); // Opentherm defines delay between request and response
-    message.type = OT_MSGTYPE_UNKNOWN_DATAID; // construct fake response
-    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
-  } else {
-    if (OPENTHERM::isSent() || OPENTHERM::isIdle() || OPENTHERM::isError()) { // wait for request from thermostat
-      OPENTHERM::listen(THERMOSTAT_IN, -1);
-    }
-    OpenthermData dummy;
-    dummy.type = OT_MSGTYPE_UNKNOWN_DATAID;
-    dummy.id = OT_MSGID_STATUS;
-    dummy.valueHB = (loops >> 8) & 0xFF;
-    dummy.valueLB = loops & 0xFF;
-    Sent_OT_Data(dummy);
-  }
+  boiler.Loop();
+/*
   delay(1000);
+*/
 }
 
@@ -132,10 +110,2 @@
     }
 }
-
-void  listenAfterResponse () {
-  Serial.print("<- ");
-  OPENTHERM::printToSerial(message);
-  Serial.println();
-  Serial.println();
-  OPENTHERM::listen(THERMOSTAT_IN, -1);
-}
