From 5b084abb15f51345d98cd169ed28a43d48292a9c Mon Sep 17 00:00:00 2001
From: "s.oezguer" <s.oezguer@b2563226-3b6e-f880-5363-0e5704bc5351>
Date: Fri, 11 May 2012 11:21:09 +0000
Subject: [PATCH] patch: http://forum.ardumote.com/viewtopic.php?f=2&t=48

---
 RCSwitch.cpp | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/RCSwitch.cpp b/RCSwitch.cpp
index e5f1e21..4de8583 100644
--- a/RCSwitch.cpp
+++ b/RCSwitch.cpp
@@ -5,6 +5,7 @@
   Contributors:
   - Andre Koehler / info(at)tomate-online(dot)de
   - Gordeev Andrey Vladimirovich / gordeev(at)openpyro(dot)com
+  - staroflaw  / http://forum.ardumote.com/viewtopic.php?f=2&t=48
   
   Project home: http://code.google.com/p/rc-switch/
 
@@ -336,19 +337,22 @@ void RCSwitch::send(char* sCodeWord) {
 }
 
 void RCSwitch::transmit(int nHighPulses, int nLowPulses) {
-  
-  if (this->nTransmitterPin != -1) {
-    if (this->nReceiverInterrupt != -1) {
-      this->disableReceive();
+    boolean disabled_Receive = false;
+    int nReceiverInterrupt_backup = nReceiverInterrupt;
+    if (this->nTransmitterPin != -1) {
+        if (this->nReceiverInterrupt != -1) {
+            this->disableReceive();
+            disabled_Receive = true;
+        }
+        digitalWrite(this->nTransmitterPin, HIGH);
+        delayMicroseconds( this->nPulseLength * nHighPulses);
+        digitalWrite(this->nTransmitterPin, LOW);
+        delayMicroseconds( this->nPulseLength * nLowPulses);
+        if(disabled_Receive){
+            this->enableReceive(nReceiverInterrupt_backup);
+        }
     }
-    digitalWrite(this->nTransmitterPin, HIGH);
-    delayMicroseconds( this->nPulseLength * nHighPulses);
-    digitalWrite(this->nTransmitterPin, LOW);
-    delayMicroseconds( this->nPulseLength * nLowPulses);
-    this->enableReceive();
-  }
 }
-
 /**
  * Sends a "0" Bit
  *                       _    
-- 
GitLab