   Serial.println("Getting rival's move...");
   boolean notMove = true;
   int rivalMove = -1;
-  
+
   while(notMove){
     String res = sendAndWait(MSG_GET_MOVE + SEP_CHAR_COMMANDS + player_id + END_CHAR);
     String command = getCommand(res);
-    
+
     //if wait_for_move -> delay 1000
     //if rival_move -> notFound = false, rival_move = res 2
     if (command == CMD_WAIT_FOR_MOVE){
       Serial.println("Waiting for rival's move...");
       delay(1000);
-    } else if (command == CMD_RIVAL_MOVE){
+    } 
+    else if (command == CMD_RIVAL_MOVE){
       String parameters = getParameters(res);
       String strMove = getParameter(parameters, 2);      
       rivalMove = strMove.toInt();
       notMove = false;
     }    
   }
-    
+
   return rivalMove;
 }
 
 void sendMove(int player_move){
   Serial.println("Sending move...");
   boolean notReceived = true;
-  
+
   //If ack -> notReceived = false
   //If wait_for_rival -> delay 1000
-  while(notReceived){}
-    String res = sendAndWait(MSG_DO_MOVE + SEP_CHAR_COMMANDS + player_id + SEP_CHAR_PARAMETERS  + player_move +  END_CHAR);
-    String command = getCommand(res);
-    if (command = CMD_ACK){
-      Serial.println("Sent");
-      notReceived = false;
-    } else if (command == CMD_WAIT_FOR_RIVAL){
-      Serial.println("Waiting for the rival to retrieve previous move...");
-      delay(1000);
-    }  
+  while(notReceived){
+  }
+  String res = sendAndWait(MSG_DO_MOVE + SEP_CHAR_COMMANDS + player_id + SEP_CHAR_PARAMETERS  + player_move +  END_CHAR);
+  String command = getCommand(res);
+  if (command = CMD_ACK){
+    Serial.println("Sent");
+    notReceived = false;
+  } 
+  else if (command == CMD_WAIT_FOR_RIVAL){
+    Serial.println("Waiting for the rival to retrieve previous move...");
+    delay(1000);
+  }  
 }
 
 void sendMsg(String msg){
-  //TODO
+  Serial1.print(msg);
 }
 String sendAndWait(String msg){ 
-  //TODO
-  return "foo"; 
+  Serial1.print(msg);
+  
+  // Wait for the reply
+  String res = "";
+  while (Serial1.available()){
+      char data = Serial1.read();
+      res += data;   
+    }
+  
+  return res; 
 }
 
 

void setup() {  
  Serial.begin(9600);
  Serial.println("Setup...");
  // 1 - Initialize the tictactoe board
  for (int i = 0; i < 9; i++){
    squares[i] = new Square(8 - i, i + 1, &_sd);

//int currentTurn = 0; //0 you, 1 opponent

// square status
int redStatus [] = {
  0,0,0,0,0,0,0,0,0};
int greenStatus [] = {
  0,0,0,0,0,0,0,0,0};
int previousGreenStatus [] = {
  0,0,0,0,0,0,0,0,0};

// conditions for victory
int winConditions [][9] = {
  {
    1,1,1,0,0,0,0,0,0  }
  ,
  {
    0,0,0,1,1,1,0,0,0  }
  ,
  {
    0,0,0,0,0,0,1,1,1  }
  ,
  {
    1,0,0,1,0,0,1,0,0  }
  ,
  {
    0,1,0,0,1,0,0,1,0  }
  ,
  {
    0,0,1,0,0,1,0,0,1  }
  ,
  {
    1,0,0,0,1,0,0,0,1  }
  ,
  {
    0,0,1,0,1,0,1,0,0  }
};

boolean redVictory = false;
