         i++;
         delay(20);
     }
-    
-    if(i > 0)
-    {
-        //check if there's any data sent from the remote bluetooth shield
-        recv_str[i] = '\0';
-        Serial.print("From BT: ");
-        Serial.println((char *)recv_str);
 
-        blueToothSerial.print("Return: ");
-        blueToothSerial.println((char *)recv_str);
-    }
-
-   //  String bluetooth_rx_buffer = "";
-
- //   blueToothSerial.listen();
-
-/*
-    while (blueToothSerial.available()) 
-    {
-        char inByte = blueToothSerial.read();
-        
-      //  Serial.print("From BT: ");
-        Serial.print((char)inByte);
-
-delay(50);
-      //  blueToothSerial.print("Return: ");
-      //  blueToothSerial.print((char)inByte);
-    }
-
-*/
-}
-
-//used for compare two string, return 0 if one equals to each other
-int strcmp(char *a, char *b)
-{
-    unsigned int ptr = 0;
-    while(a[ptr] != '\0')
-    {
-        if(a[ptr] != b[ptr]) return -1;
-        ptr++;
-    }
-    return 0;
+    return i;
 }
 
 //configure the Bluetooth through AT commands
 int setupBlueToothConnection()
 {
-   /** #if MASTER
-    Serial.println("this is MASTER\r\n");
-    #else
-    Serial.println("this is SLAVE\r\n");
-    #endif
-    */
-
     Serial.print("Setting up Bluetooth link\r\n");
     delay(3500);//wait for module restart
 

#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 2
#define TxD 3



void loop() 
{
    int readBytes = recvMsg();
    if(readBytes > 0)
    {
        //check if there's any data sent from the remote bluetooth shield
        //recv_str[readBytes] = '\0';
        Serial.print("From BT: ");
        Serial.println((char *)recv_str);

        blueToothSerial.print("Return: ");
        blueToothSerial.println((char *)recv_str);
    }

}

// receives data from the bluetooth
int recvMsg()
{
    int i = 0;
    while(blueToothSerial.available())
    {                                              
