   }
     
 }
+
+void sendMsg(String msg) {
+  Serial.print(deviceId);
+  Serial.print(": ");
+  Serial.print(msg);
+  Serial.println();
+
+  XBee.print(deviceId);
+  XBee.print(": ");
+  XBee.print(msg);
+  XBee.println();
+
+}
+
+void readXBeeString (char *strArray) {
+  int i = 0;
+  if(!XBee.available()) {
+    return;
+  }
+  while (XBee.available()) {
+    strArray[i] = XBee.read();
+    i++;
+  }
+  Serial.print("read XBee: ");
+  Serial.println(strArray);
+  // sendMsg(XBeeInString);
+}

    Serial.println(results.value, HEX);
    // Serial.println(results.decode_type);
    
    XBee.print("IR: ");
    XBee.println(results.value, HEX);

    switch(results.value) {
      case signalInit:
        Serial.println("singalStart");
        XBee.println("singalStart");
        break;
      
      case signalVerify:
        Serial.println("singalVerify");
        XBee.println("singalVerify");
        break;

      case signalConfirm:
        Serial.println("singalConfirm");
        XBee.println("singalConfirm");
        break;

    }

    irrecv.resume(); // Receive the next value



void loop() // run over and over
{
  memset(XBeeInString, 0, 50);
  

  readXBeeString(XBeeInString);
  char c = XBeeInString[0];
  if(c != '\0') {
    sendMsg(XBeeInString);  
  }
  
  
  if(Serial.available()) {
    Serial.write(Serial.read());
