Browse Source

Parse and validate message

Robert Marshall 5 years ago
parent
commit
589067ab08
1 changed files with 10 additions and 1 deletions
  1. 10 1
      Receiver/src/main.cpp

+ 10 - 1
Receiver/src/main.cpp

@@ -4,6 +4,14 @@
 RH_ASK _driver;
 unsigned int _output = 12;
 
+bool validateMessage(char* message){
+	return strncmp("LED On: ", message, 8) == 0; //returns 0 on match
+}
+
+bool parseMessage(char* message){
+	return validateMessage(message) && message[8] == '1';
+}
+
 void setup(){
 	pinMode(_output, OUTPUT);
 	Serial.begin(9600);
@@ -20,6 +28,7 @@ void loop(){
 		Serial.print("Message: ");
 		Serial.println((char *)buf);
 
-		digitalWrite(_output, buf[8] == '1');
+		Serial.println(validateMessage((char *)buf));
+		Serial.println(parseMessage((char *)buf));
 	}
 }