Created
April 9, 2017 08:49
-
-
Save zaifz/971c26db064064812c4508b893280ec1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool didRemoveNoise() { | |
bool didRemoveNoise = false; | |
while (didRemoveNoise == false) { | |
// Read Serial input | |
String inputData; | |
char c; | |
while (esp.available() > 0) { | |
c = esp.read(); | |
inputData.concat(c); | |
} | |
inputData.trim(); | |
Serial.println("Validating " + inputData); | |
if (previousData != "") { | |
Serial.println("Previous data: " + previousData); | |
// If true, noise removed, else stay in the loop | |
if (previousData.compareTo(inputData) == 0) { | |
Serial.println("if "); | |
didRemoveNoise = true; | |
Serial.println("Received"); | |
esp.println("ack"); | |
} else { | |
Serial.println("else "); | |
previousData = inputData; | |
} | |
} | |
else { | |
previousData = inputData; | |
} | |
delay(1000); | |
} | |
return didRemoveNoise; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment